jsynoptic.data
Class ExpressionDataSource

java.lang.Object
  extended by simtools.data.ValueProvider
      extended by simtools.data.DataSource
          extended by jsynoptic.data.ExpressionDataSource
All Implemented Interfaces:
DataSourceListener

public class ExpressionDataSource
extends DataSource
implements DataSourceListener

A data source that evaluate a mathematical expression on other sources to compute its values


Field Summary
protected static java.lang.String EXPRESSION_DATA_SOURCE_MARKER
           
protected  DataInfo info
           
protected  double max
           
protected  long maxIndex
           
protected  double min
          min max values if computed
protected  long minIndex
           
protected  boolean minmaxOk
           
protected  ExpressionNode rootNode
           
protected  java.util.Set variables
           
 
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
ExpressionDataSource(DataInfo di, ExpressionNode rootNode)
           
 
Method Summary
 void changeExpression(java.lang.String exp, ExpressionNode node)
           
 void cleanup()
          Remove the listeners
 long computeLastIndex()
           
 java.lang.Object computeMax()
           
 java.lang.Object computeMin()
          Force the computation if possible.
protected  void computeMinMax()
           
 long computeStartIndex()
           
 void DataSourceIndexRangeChanged(DataSource ds, long startIndex, long lastIndex)
          Called when the range of valid index changed
 void DataSourceInfoChanged(DataSource ds, DataInfo newInfo)
          Called when the information about the data source changed
 void DataSourceOrderChanged(DataSource ds, int newOrder)
          If defined, called when the order of the source changed.
 void DataSourceReplaced(DataSource oldData, DataSource newData)
          Called when a data source is replaced by another one
 void DataSourceValueChanged(DataSource ds, long minIndex, long maxIndex)
          Called when at least a value changed in the data source.
 void DataSourceValueRangeChanged(DataSource ds)
          Called when the range of possible values changed, if defined.
 java.lang.String getDataSourceInformationClass()
          This method provide the UI Data source information class name.
 DataInfo getInformation()
           
 long getLastIndex()
           
 java.lang.Object getMax()
           
 java.lang.Object getMin()
          Return values if possibly only, without expensive computations.
 DataSource[] getSourceDependencies()
          Returns an array of dependant data sources when serializing.
 long getStartIndex()
           
 java.lang.Object getValue(long index)
           
 java.util.Set getVariables()
           
 boolean isComparable()
          Check if the values are comparable with each other.
 java.lang.String toString()
           
 
Methods inherited from class simtools.data.DataSource
addEndNotificationListener, addListener, computeSortedOrder, createEmptyDataSource, equals, getAuxiliarySources, getByteMax, getByteMin, getChoiceFormat, getDoubleMax, getDoubleMin, getFloatMax, getFloatMin, getIntegerMax, getIntegerMin, getLongMax, getLongMin, getShortMax, getShortMin, getSortedOrder, isAuxiliary, 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, getKind, getLongValue, getObjectValue, getShortValue, valueClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rootNode

protected ExpressionNode rootNode

variables

protected java.util.Set variables

info

protected DataInfo info

minIndex

protected long minIndex

maxIndex

protected long maxIndex

min

protected double min
min max values if computed


max

protected double max

minmaxOk

protected boolean minmaxOk

EXPRESSION_DATA_SOURCE_MARKER

protected static java.lang.String EXPRESSION_DATA_SOURCE_MARKER
Constructor Detail

ExpressionDataSource

public ExpressionDataSource(DataInfo di,
                            ExpressionNode rootNode)
Method Detail

getVariables

public java.util.Set getVariables()
Returns:
Returns the variables.

getInformation

public DataInfo getInformation()
Overrides:
getInformation in class DataSource

computeMin

public java.lang.Object computeMin()
                            throws UnsupportedOperation
Description copied from class: DataSource
Force the computation if possible. The operation may take some time.

Overrides:
computeMin in class DataSource
Throws:
UnsupportedOperation

computeMax

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

getMin

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

Overrides:
getMin in class DataSource
Throws:
UnsupportedOperation

getMax

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

computeMinMax

protected void computeMinMax()
                      throws UnsupportedOperation
Throws:
UnsupportedOperation

changeExpression

public void changeExpression(java.lang.String exp,
                             ExpressionNode node)
Parameters:
exp -
node -

cleanup

public void cleanup()
Remove the listeners


getValue

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

DataSourceValueChanged

public void DataSourceValueChanged(DataSource ds,
                                   long minIndex,
                                   long maxIndex)
Description copied from interface: DataSourceListener
Called when at least a value changed in the data source. The listener shall then get the values in the given range again, if it is interested by the values in that range.

Specified by:
DataSourceValueChanged in interface DataSourceListener
Parameters:
ds - The data source that changed
minIndex - Lower bound of the range where values changed
maxIndex - Higher bound of the range where values changed

DataSourceIndexRangeChanged

public void DataSourceIndexRangeChanged(DataSource ds,
                                        long startIndex,
                                        long lastIndex)
Description copied from interface: DataSourceListener
Called when the range of valid index changed

Specified by:
DataSourceIndexRangeChanged in interface DataSourceListener
Parameters:
ds - The data source that changed
startIndex - The new start Index
lastIndex - The new last index

DataSourceInfoChanged

public void DataSourceInfoChanged(DataSource ds,
                                  DataInfo newInfo)
Description copied from interface: DataSourceListener
Called when the information about the data source changed

Specified by:
DataSourceInfoChanged in interface DataSourceListener
Parameters:
ds - The data source that changed

DataSourceValueRangeChanged

public void DataSourceValueRangeChanged(DataSource ds)
Description copied from interface: DataSourceListener
Called when the range of possible values changed, if defined.

Specified by:
DataSourceValueRangeChanged in interface DataSourceListener
Parameters:
ds - The data source that changed

DataSourceOrderChanged

public void DataSourceOrderChanged(DataSource ds,
                                   int newOrder)
Description copied from interface: DataSourceListener
If defined, called when the order of the source changed. See the sortedOrder() in the Datasource class for more information.

Specified by:
DataSourceOrderChanged in interface DataSourceListener
Parameters:
ds - The data source that changed

DataSourceReplaced

public void DataSourceReplaced(DataSource oldData,
                               DataSource newData)
Description copied from interface: DataSourceListener
Called when a data source is replaced by another one

Specified by:
DataSourceReplaced in interface DataSourceListener

computeLastIndex

public long computeLastIndex()
                      throws UnsupportedOperation
Overrides:
computeLastIndex in class DataSource
Throws:
UnsupportedOperation

computeStartIndex

public long computeStartIndex()
                       throws UnsupportedOperation
Overrides:
computeStartIndex in class DataSource
Throws:
UnsupportedOperation

getLastIndex

public long getLastIndex()
                  throws UnsupportedOperation
Overrides:
getLastIndex in class DataSource
Throws:
UnsupportedOperation

getStartIndex

public long getStartIndex()
                   throws UnsupportedOperation
Overrides:
getStartIndex in class DataSource
Throws:
UnsupportedOperation

isComparable

public boolean isComparable()
Description copied from class: DataSource
Check if the values are comparable with each other. If they are, the sortedOrder() function tells if they are also sorted.

Overrides:
isComparable in class DataSource

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSourceDependencies

public DataSource[] getSourceDependencies()
Description copied from class: DataSource
Returns an array of dependant data sources when serializing. Think carefully before using this feature, as it is usually not needed.
You need to overload this function if, and only if, this data source provider recursively depends on other data sources beeing already written to work correctly.
WARNING: Cyclic dependencies would result in an infinite recursion loop.

Overrides:
getSourceDependencies in class DataSource

getDataSourceInformationClass

public java.lang.String getDataSourceInformationClass()
Description copied from class: DataSource
This method provide the UI Data source information class name. Should be overloaded in sub classes to return specified information

Overrides:
getDataSourceInformationClass in class DataSource
Returns:
the box