simtools.data
Class DynamicDataSource

java.lang.Object
  extended by simtools.data.ValueProvider
      extended by simtools.data.DataSource
          extended by simtools.data.DynamicDataSource
Direct Known Subclasses:
DataSourceAnimator

public class DynamicDataSource
extends DataSource


Field Summary
protected  boolean autoRegister
          Set this to true to register the values as soon as they are set True by default, but this behaviour is not the same as the source collection so it can be set off
protected  byte cachedByte
          current / cached values current values are positioned by setvalue but not registered yet cached values are registered and returned by the collection until the next register.
protected  double cachedDouble
           
protected  float cachedFloat
           
protected  int cachedInteger
           
protected  long cachedLong
           
protected  java.lang.Object cachedObject
           
protected  short cachedShort
           
protected  byte currentByte
          current / cached values current values are positioned by setvalue but not registered yet cached values are registered and returned by the collection until the next register.
protected  double currentDouble
           
protected  float currentFloat
           
protected  int currentInteger
           
protected  long currentLong
           
protected  java.lang.Object currentObject
           
protected  short currentShort
           
protected  boolean hasValue
          Whether or not values were set, or if they are unititialized.
 DataInfo info
          This class contains info necessary to handle the data sources.
protected  int kind
          See valueProvider
protected  long lastIndex
           
protected  byte maxByte
           
protected  double maxDouble
           
protected  float maxFloat
           
protected  int maxInteger
           
protected  long maxLong
           
protected  java.lang.Object maxObject
           
protected  short maxShort
           
protected  byte minByte
           
protected  double minDouble
           
protected  float minFloat
           
protected  int minInteger
           
protected  long minLong
           
protected  java.lang.Object minObject
           
protected  short minShort
           
 
Fields inherited from class simtools.data.DataSource
endNotificationListeners, listeners, sortedOrder
 
Fields inherited from class simtools.data.ValueProvider
ByteProvider, DoubleProvider, FloatProvider, IntegerProvider, LongProvider, ObjectProvider, ShortProvider
 
Constructor Summary
DynamicDataSource(DataInfo di, int kind)
          Builds a new dynamic data source with the given data information.
DynamicDataSource(DataInfo di, int kind, int delay)
          Builds a new dynamic data source with the given data information, and backed by a data buffer of the given size
 
Method Summary
 void bufferize(int delay)
          Adds a buffer to this source so it can keep previous values in memory
protected  void changeInfo(DataInfo di)
          Change our own information.
 long computeLastIndex()
           
 boolean computeMinMax()
          Compute the min and the max of this data source
 long computeStartIndex()
           
 byte getByteMax()
           
 byte getByteMin()
           
 double getDoubleMax()
           
 double getDoubleMin()
           
 float getFloatMax()
           
 float getFloatMin()
           
 DataInfo getInformation()
           
 int getIntegerMax()
           
 int getIntegerMin()
           
 int getKind()
          The kind of this provider may be used fo optimization purpose.
 long getLastIndex()
           
 long getLongMax()
           
 long getLongMin()
           
 java.lang.Object getMax()
           
 java.lang.Object getMin()
          Other functions have a reasonable default implementation
 short getShortMax()
           
 short getShortMin()
           
 long getStartIndex()
           
 java.lang.Object getValue(long index)
           
 boolean isAutoRegister()
           
 boolean isComparable(int i)
           
protected  void registerNewValue()
          Call this function once you have set up all the values with setValue.
 void setAutoRegister(boolean autoRegister)
           
protected  void setByteValue(byte v)
          Sets the value of this Datasource to the byte v
protected  void setDoubleValue(double v)
          Sets the value of this Datasource to the double v
protected  void setFloatValue(float v)
          Sets the value of this Datasource to the float v
protected  void setIntegerValue(int v)
          Sets the value of this Datasource to the int v
protected  void setLongValue(long v)
          Sets the value of this Datasource to the long v
protected  void setObjectValue(java.lang.Object v)
          Sets the value of this Datasource to the Object v
protected  void setShortValue(short v)
          Sets the value of this Datasource to the short v
 java.lang.Class valueClass()
          Returns the more specialized superclass of all objects returned by this provider.
 
Methods inherited from class simtools.data.DataSource
addEndNotificationListener, addListener, computeMax, computeMin, computeSortedOrder, createEmptyDataSource, equals, getAuxiliarySources, getChoiceFormat, getDataSourceInformationClass, getSortedOrder, getSourceDependencies, isAuxiliary, isComparable, isCompound, notifyEndNotificationListeners, notifyListenersForDataReplaced, notifyListenersForDataReplaced, notifyListenersForIndexRangeChange, notifyListenersForInfoChange, notifyListenersForOrderChange, notifyListenersForValueChange, notifyListenersForValueRangeChange, removeEndNotificationListener, removeListener, setSlice, sortedOrder, updateSortedOrder
 
Methods inherited from class simtools.data.ValueProvider
getByteValue, getDoubleValue, getFloatValue, getIntegerValue, getLongValue, getObjectValue, getShortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

info

public DataInfo info
This class contains info necessary to handle the data sources. The vector has the same size as this object (reminder: Vector inheritance).


lastIndex

protected long lastIndex

autoRegister

protected boolean autoRegister
Set this to true to register the values as soon as they are set True by default, but this behaviour is not the same as the source collection so it can be set off


kind

protected int kind
See valueProvider


hasValue

protected boolean hasValue
Whether or not values were set, or if they are unititialized. Itself false when uninitialized, so OK


currentByte

protected byte currentByte
current / cached values current values are positioned by setvalue but not registered yet cached values are registered and returned by the collection until the next register. current values correspond to currentIndex, cached values to the next.


cachedByte

protected byte cachedByte
current / cached values current values are positioned by setvalue but not registered yet cached values are registered and returned by the collection until the next register. current values correspond to currentIndex, cached values to the next.


minByte

protected byte minByte

maxByte

protected byte maxByte

currentShort

protected short currentShort

cachedShort

protected short cachedShort

minShort

protected short minShort

maxShort

protected short maxShort

currentInteger

protected int currentInteger

cachedInteger

protected int cachedInteger

minInteger

protected int minInteger

maxInteger

protected int maxInteger

currentLong

protected long currentLong

cachedLong

protected long cachedLong

minLong

protected long minLong

maxLong

protected long maxLong

currentFloat

protected float currentFloat

cachedFloat

protected float cachedFloat

minFloat

protected float minFloat

maxFloat

protected float maxFloat

currentDouble

protected double currentDouble

cachedDouble

protected double cachedDouble

minDouble

protected double minDouble

maxDouble

protected double maxDouble

currentObject

protected java.lang.Object currentObject

cachedObject

protected java.lang.Object cachedObject

minObject

protected java.lang.Object minObject

maxObject

protected java.lang.Object maxObject
Constructor Detail

DynamicDataSource

public DynamicDataSource(DataInfo di,
                         int kind)
Builds a new dynamic data source with the given data information. Only the last value will be available, no buffer is set up.

Parameters:
di - the data information for this source (name, comment, unit...)
kind - the type of the data source. @see ValueProvider

DynamicDataSource

public DynamicDataSource(DataInfo di,
                         int kind,
                         int delay)
Builds a new dynamic data source with the given data information, and backed by a data buffer of the given size

Parameters:
di - the data information for this source (name, comment, unit...)
kind - the type of the data source. @see ValueProvider
delay - the size of the buffer for past values
Method Detail

bufferize

public void bufferize(int delay)
               throws UnsupportedOperation
Adds a buffer to this source so it can keep previous values in memory

Throws:
UnsupportedOperation

isAutoRegister

public boolean isAutoRegister()
Returns:
Returns the autoRegister.

setAutoRegister

public void setAutoRegister(boolean autoRegister)
Parameters:
autoRegister - The autoRegister to set.

getMin

public java.lang.Object getMin()
                        throws UnsupportedOperation
Other functions have a reasonable default implementation

Overrides:
getMin in class DataSource
Throws:
UnsupportedOperation

getMax

public java.lang.Object getMax()
                        throws UnsupportedOperation
Overrides:
getMax in class DataSource
Throws:
UnsupportedOperation

getByteMin

public byte getByteMin()
                throws DataException
Overrides:
getByteMin in class DataSource
Throws:
DataException

getByteMax

public byte getByteMax()
                throws DataException
Overrides:
getByteMax in class DataSource
Throws:
DataException

getShortMin

public short getShortMin()
                  throws DataException
Overrides:
getShortMin in class DataSource
Throws:
DataException

getShortMax

public short getShortMax()
                  throws DataException
Overrides:
getShortMax in class DataSource
Throws:
DataException

getIntegerMin

public int getIntegerMin()
                  throws DataException
Overrides:
getIntegerMin in class DataSource
Throws:
DataException

getIntegerMax

public int getIntegerMax()
                  throws DataException
Overrides:
getIntegerMax in class DataSource
Throws:
DataException

getLongMin

public long getLongMin()
                throws DataException
Overrides:
getLongMin in class DataSource
Throws:
DataException

getLongMax

public long getLongMax()
                throws DataException
Overrides:
getLongMax in class DataSource
Throws:
DataException

getFloatMin

public float getFloatMin()
                  throws DataException
Overrides:
getFloatMin in class DataSource
Throws:
DataException

getFloatMax

public float getFloatMax()
                  throws DataException
Overrides:
getFloatMax in class DataSource
Throws:
DataException

getDoubleMin

public double getDoubleMin()
                    throws DataException
Overrides:
getDoubleMin in class DataSource
Throws:
DataException

getDoubleMax

public double getDoubleMax()
                    throws DataException
Overrides:
getDoubleMax in class DataSource
Throws:
DataException

computeMinMax

public boolean computeMinMax()
                      throws UnsupportedOperation
Compute the min and the max of this data source

Returns:
- true if min or max values have changed
Throws:
UnsupportedOperation

isComparable

public boolean isComparable(int i)

getStartIndex

public long getStartIndex()
Overrides:
getStartIndex in class DataSource

getLastIndex

public long getLastIndex()
Overrides:
getLastIndex in class DataSource

computeStartIndex

public long computeStartIndex()
Overrides:
computeStartIndex in class DataSource

computeLastIndex

public long computeLastIndex()
Overrides:
computeLastIndex in class DataSource

changeInfo

protected void changeInfo(DataInfo di)
Change our own information. May be called any time, and will notify the our listeners.


setByteValue

protected void setByteValue(byte v)
Sets the value of this Datasource to the byte v

Parameters:
v - the byte value to set

setShortValue

protected void setShortValue(short v)
Sets the value of this Datasource to the short v

Parameters:
v - the short value to set

setIntegerValue

protected void setIntegerValue(int v)
Sets the value of this Datasource to the int v

Parameters:
v - the int value to set

setLongValue

protected void setLongValue(long v)
Sets the value of this Datasource to the long v

Parameters:
v - the long value to set

setFloatValue

protected void setFloatValue(float v)
Sets the value of this Datasource to the float v

Parameters:
v - the float value to set

setDoubleValue

protected void setDoubleValue(double v)
Sets the value of this Datasource to the double v

Parameters:
v - the double value to set

setObjectValue

protected void setObjectValue(java.lang.Object v)
Sets the value of this Datasource to the Object v

Parameters:
v - the Object value to set

registerNewValue

protected void registerNewValue()
Call this function once you have set up all the values with setValue. The last value is reused if no new value is set. Note that by default, auto registering is true, so just calling setXXXValue will do the job

Parameters:
dsnum -
v -

getInformation

public DataInfo getInformation()
Overrides:
getInformation in class DataSource

getValue

public java.lang.Object getValue(long index)
                          throws DataException
Specified by:
getValue in class ValueProvider
Throws:
DataException

getKind

public int getKind()
Description copied from class: ValueProvider
The kind of this provider may be used fo optimization purpose. This is just an indication for getXXXValue typed functions.

Overrides:
getKind in class ValueProvider
Returns:
the kind of this provider

valueClass

public java.lang.Class valueClass()
Description copied from class: ValueProvider
Returns the more specialized superclass of all objects returned by this provider. Returns Object by default in the base implementation, subclass should specialize if possible.

Overrides:
valueClass in class ValueProvider