simtools.data.async
Class StreamingMSDataSource.StreamingLabelSource

java.lang.Object
  extended by simtools.data.ValueProvider
      extended by simtools.data.DataSource
          extended by simtools.data.async.TimeStampedDataSource
              extended by simtools.data.async.StreamingMSDataSource.StreamingLabelSource
Enclosing class:
StreamingMSDataSource

public class StreamingMSDataSource.StreamingLabelSource
extends TimeStampedDataSource


Nested Class Summary
 
Nested classes/interfaces inherited from class simtools.data.async.TimeStampedDataSource
TimeStampedDataSource.TimeSource
 
Field Summary
protected  double _dmax
           
protected  double _dmin
           
protected  double[] _l
           
protected  int _lastIndex
           
protected  int _maxSize
           
protected  double _minDuration
           
protected  int _size
           
protected  int _startIndex
           
protected  java.text.ChoiceFormat choiceFormat
           
protected  java.util.HashMap mapping
          We store numerical values instead of received string values.
protected  int mappingCounter
           
 
Fields inherited from class simtools.data.async.TimeStampedDataSource
_auxiliaries
 
Fields inherited from class simtools.data.DataSource
endNotificationListeners, listeners, sortedOrder
 
Fields inherited from class simtools.data.ValueProvider
ByteProvider, DoubleProvider, FloatProvider, IntegerProvider, kind, LongProvider, ObjectProvider, ShortProvider
 
Constructor Summary
StreamingMSDataSource.StreamingLabelSource(java.lang.String type, java.lang.String name, int minSize, int maxSize, double minDuration)
           
 
Method Summary
 void addValues(java.lang.String l)
          Add a label value
protected  void computeMinMax()
           
 java.util.Collection getAuxiliarySources()
          If the data source is compund return the collection of auxiliary data sources
 java.text.ChoiceFormat getChoiceFormat()
          This method allows you to attach a format to data source values
 double getDoubleMax()
           
 double getDoubleMin()
           
 double getDoubleValue(long index)
          Optimized accessor for double values.
 double getEnd()
           
 long getLastIndex()
           
 long getLongValue(long index)
          Optimized accessor for long values.
 java.lang.Object getMax()
           
 java.lang.Object getMin()
          Return values if possibly only, without expensive computations.
 double getNumericalValue(java.lang.String value)
           
 double getStart()
           
 long getStartIndex()
           
 java.lang.Object getValue(long index)
           
protected  void initialiseIndex(int minSize)
           
 boolean isAuxiliary()
           
 boolean isCompound()
          Checks if a data source is compound, i.e. if it provides auxiliary data sources
 boolean isValid()
           
 
Methods inherited from class simtools.data.async.TimeStampedDataSource
createEmptyDataSource, getCollection, getDataSourceInformationClass, getInfo, getInformation, getName, getTime, setInfo, setMax, setMin, setMinmax, setTime, toString
 
Methods inherited from class simtools.data.DataSource
addEndNotificationListener, addListener, computeLastIndex, computeMax, computeMin, computeSortedOrder, computeStartIndex, equals, getByteMax, getByteMin, getFloatMax, getFloatMin, getIntegerMax, getIntegerMin, getLongMax, getLongMin, getShortMax, getShortMin, getSortedOrder, getSourceDependencies, isComparable, notifyEndNotificationListeners, notifyListenersForDataReplaced, notifyListenersForDataReplaced, notifyListenersForIndexRangeChange, notifyListenersForInfoChange, notifyListenersForOrderChange, notifyListenersForValueChange, notifyListenersForValueRangeChange, removeEndNotificationListener, removeListener, setSlice, sortedOrder, updateSortedOrder
 
Methods inherited from class simtools.data.ValueProvider
getByteValue, getFloatValue, getIntegerValue, getKind, getObjectValue, getShortValue, valueClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_l

protected double[] _l

_startIndex

protected int _startIndex

_lastIndex

protected int _lastIndex

_dmin

protected double _dmin

_dmax

protected double _dmax

_size

protected int _size

_minDuration

protected final double _minDuration

_maxSize

protected int _maxSize

mapping

protected java.util.HashMap mapping
We store numerical values instead of received string values. An HashMap (Double --> String) converts them into string values.


mappingCounter

protected int mappingCounter

choiceFormat

protected java.text.ChoiceFormat choiceFormat
Constructor Detail

StreamingMSDataSource.StreamingLabelSource

public StreamingMSDataSource.StreamingLabelSource(java.lang.String type,
                                                  java.lang.String name,
                                                  int minSize,
                                                  int maxSize,
                                                  double minDuration)
                                           throws java.io.IOException,
                                                  TimeStampedDataSourceCollection.InvalidFormatException
Throws:
java.io.IOException
TimeStampedDataSourceCollection.InvalidFormatException
Method Detail

initialiseIndex

protected void initialiseIndex(int minSize)

getValue

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

getDoubleValue

public double getDoubleValue(long index)
                      throws DataException
Description copied from class: ValueProvider
Optimized accessor for double values. If the provider can provide doubles directly, then it should override this method. Otherwise, the default implementation will do its best to convert the Object returned by getValue() to a double. This conversion also parses strings, and returns 0 if it failed. An exception is thrown if, and only if, getValue throws it.

Specified by:
getDoubleValue in class TimeStampedDataSource
Throws:
DataException

addValues

public void addValues(java.lang.String l)
Add a label value

Parameters:
l -

getStart

public double getStart()
                throws DataException
Specified by:
getStart in class TimeStampedDataSource
Throws:
DataException

getStartIndex

public long getStartIndex()
                   throws UnsupportedOperation
Specified by:
getStartIndex in class TimeStampedDataSource
Throws:
UnsupportedOperation

getEnd

public double getEnd()
              throws DataException
Specified by:
getEnd in class TimeStampedDataSource
Throws:
DataException

getLastIndex

public long getLastIndex()
                  throws UnsupportedOperation
Specified by:
getLastIndex in class TimeStampedDataSource
Throws:
UnsupportedOperation

computeMinMax

protected void computeMinMax()
                      throws UnsupportedOperation
Specified by:
computeMinMax in class TimeStampedDataSource
Throws:
UnsupportedOperation

getDoubleMin

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

getMin

public java.lang.Object getMin()
Description copied from class: DataSource
Return values if possibly only, without expensive computations.

Overrides:
getMin in class TimeStampedDataSource
Returns:
Returns the min.

getDoubleMax

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

getMax

public java.lang.Object getMax()
Overrides:
getMax in class TimeStampedDataSource
Returns:
Returns the max.

getLongValue

public long getLongValue(long index)
                  throws DataException
Description copied from class: ValueProvider
Optimized accessor for long values. If the provider can provide longs directly, then it should override this method. Otherwise, the default implementation will do its best to convert the Object returned by getValue() to a long. This conversion also parses strings, and returns 0 if it failed. An exception is thrown if, and only if, getValue throws it.

Overrides:
getLongValue in class ValueProvider
Throws:
DataException

getAuxiliarySources

public java.util.Collection getAuxiliarySources()
Description copied from class: DataSource
If the data source is compund return the collection of auxiliary data sources

Overrides:
getAuxiliarySources in class TimeStampedDataSource
Returns:
the auxilary data source collection or null if not a compound data source

isCompound

public boolean isCompound()
Description copied from class: DataSource
Checks if a data source is compound, i.e. if it provides auxiliary data sources

Overrides:
isCompound in class TimeStampedDataSource
Returns:
true if it is compound

isAuxiliary

public boolean isAuxiliary()
Overrides:
isAuxiliary in class DataSource
Returns:
true if the data source is an auxiliary data source

isValid

public boolean isValid()
Specified by:
isValid in class TimeStampedDataSource
Returns:
true if it is valid

getChoiceFormat

public java.text.ChoiceFormat getChoiceFormat()
Description copied from class: DataSource
This method allows you to attach a format to data source values

Overrides:
getChoiceFormat in class DataSource
Returns:
datasource choiceformat

getNumericalValue

public double getNumericalValue(java.lang.String value)