StringCurveBuffer.java :  » Graphic-Library » GLIPS-Graffiti-editor-1.5 » fr » itris » glips » extension » jwidget » trends » runtime » model » buffer » Java Open Source

Java Open Source » Graphic Library » GLIPS Graffiti editor 1.5 
GLIPS Graffiti editor 1.5 » fr » itris » glips » extension » jwidget » trends » runtime » model » buffer » StringCurveBuffer.java
package fr.itris.glips.extension.jwidget.trends.runtime.model.buffer;

import java.util.*;

/**
 * the class of a curve buffer containing string values
 * @author ITRIS, Jordi SUC
 */
public class StringCurveBuffer extends CurveBuffer {
  
  /**
   * the constructor of the class
   * @param tagName the tag name whose values are recorded in this buffer
     * @param isEnumeratedTag whether the tag is an enumerated one
   * @param bufferSize the size of the buffer
   */
  public StringCurveBuffer(String tagName, boolean isEnumeratedTag, int bufferSize){
    
    super(tagName, isEnumeratedTag, bufferSize);
  }
  
  @Override
  public synchronized void addTagValue(Object newValue) {
    
    //checking if the buffer is full, if so, the first element of the sorted set is removed
    if(buffer.size()==bufferSize){
      
      buffer.remove(buffer.firstKey());
    }
    
    buffer.put(System.currentTimeMillis(), newValue);
  }
  
  @Override
  public synchronized void addTagValues(Map<Long, Object> values) {

    String sVal;
    
    for(Long horodate : values.keySet()){
      
      sVal=(String)values.get(horodate);
      
      buffer.put(horodate, sVal);
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.