simtools.data
Class DataSource

java.lang.Object
  extended by simtools.data.ValueProvider
      extended by simtools.data.DataSource
Direct Known Subclasses:
BufferedDataSource, CollectiveDataSource, DefaultEmptyDataSource, DynamicDataSource, ExpressionDataSource, LinearSource, RandomSource, RangeSource, SinusSource, SynchronousMergeDSCollection.TimeSource, TimeStampedDataSource, TimeStampedDataSource.TimeSource

public abstract class DataSource
extends ValueProvider


Field Summary
protected  ListenerManager endNotificationListeners
           
protected  ListenerManager listeners
           
protected  int sortedOrder
          Determines whether or not values are sorted. -2 : sort compute has not been performed yet -1 : values are sorted in descending order 0 : values are not sorted 1 : values are sorted in ascending order
 
Fields inherited from class simtools.data.ValueProvider
ByteProvider, DoubleProvider, FloatProvider, IntegerProvider, kind, LongProvider, ObjectProvider, ShortProvider
 
Constructor Summary
DataSource()
           
 
Method Summary
 void addEndNotificationListener(EndNotificationListener enl)
           
 void addListener(DataSourceListener dsl)
           
 long computeLastIndex()
           
 java.lang.Object computeMax()
           
 java.lang.Object computeMin()
          Force the computation if possible.
 void computeSortedOrder()
          Compute sortedOrder attribute reagarding all data source values
 long computeStartIndex()
           
protected  DataSource createEmptyDataSource()
          Create an empty data source with same references than current data source.
 boolean equals(java.lang.Object obj)
           
 java.util.Collection getAuxiliarySources()
          If the data source is compund return the collection of auxiliary data sources
 byte getByteMax()
           
 byte getByteMin()
           
 java.text.ChoiceFormat getChoiceFormat()
          This method allows you to attach a format to data source values
 java.lang.String getDataSourceInformationClass()
          This method provide the UI Data source information class name.
 double getDoubleMax()
           
 double getDoubleMin()
           
 float getFloatMax()
           
 float getFloatMin()
           
 DataInfo getInformation()
           
 int getIntegerMax()
           
 int getIntegerMin()
           
 long getLastIndex()
           
 long getLongMax()
           
 long getLongMin()
           
 java.lang.Object getMax()
           
 java.lang.Object getMin()
          Return values if possibly only, without expensive computations.
 short getShortMax()
           
 short getShortMin()
           
 int getSortedOrder()
           
 DataSource[] getSourceDependencies()
          Returns an array of dependant data sources when serializing.
 long getStartIndex()
           
 boolean isAuxiliary()
           
 boolean isComparable()
          Check if the values are comparable with each other.
 boolean isCompound()
          Checks if a data source is compound, i.e. if it provides auxiliary data sources
 void notifyEndNotificationListeners()
          Use this method only when this data source is the referer.
 void notifyListenersForDataReplaced(DataSource newData)
           
 void notifyListenersForDataReplaced(DataSource oldData, DataSource newData)
           
 void notifyListenersForIndexRangeChange(long startIndex, long lastIndex)
           
 void notifyListenersForInfoChange(DataInfo newInfo)
           
 void notifyListenersForOrderChange(int newOrder)
           
 void notifyListenersForValueChange(long minIndex, long maxIndex)
           
 void notifyListenersForValueRangeChange()
           
 void removeEndNotificationListener(EndNotificationListener enl)
           
 void removeListener(DataSourceListener dsl)
           
 void setSlice(long min, long max)
          Sets a region of interest in the DataSource.
 int sortedOrder()
          Check if the values are sorted or not.
 void updateSortedOrder()
           
 
Methods inherited from class simtools.data.ValueProvider
getByteValue, getDoubleValue, getFloatValue, getIntegerValue, getKind, getLongValue, getObjectValue, getShortValue, getValue, valueClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

protected ListenerManager listeners

endNotificationListeners

protected ListenerManager endNotificationListeners

sortedOrder

protected int sortedOrder
Determines whether or not values are sorted. -2 : sort compute has not been performed yet -1 : values are sorted in descending order 0 : values are not sorted 1 : values are sorted in ascending order

Constructor Detail

DataSource

public DataSource()
Method Detail

getMin

public java.lang.Object getMin()
                        throws UnsupportedOperation
Return values if possibly only, without expensive computations.

Throws:
UnsupportedOperation

getMax

public java.lang.Object getMax()
                        throws UnsupportedOperation
Throws:
UnsupportedOperation

getByteMin

public byte getByteMin()
                throws DataException
Throws:
DataException

getByteMax

public byte getByteMax()
                throws DataException
Throws:
DataException

getShortMin

public short getShortMin()
                  throws DataException
Throws:
DataException

getShortMax

public short getShortMax()
                  throws DataException
Throws:
DataException

getIntegerMin

public int getIntegerMin()
                  throws DataException
Throws:
DataException

getIntegerMax

public int getIntegerMax()
                  throws DataException
Throws:
DataException

getLongMin

public long getLongMin()
                throws DataException
Throws:
DataException

getLongMax

public long getLongMax()
                throws DataException
Throws:
DataException

getFloatMin

public float getFloatMin()
                  throws DataException
Throws:
DataException

getFloatMax

public float getFloatMax()
                  throws DataException
Throws:
DataException

getDoubleMin

public double getDoubleMin()
                    throws DataException
Throws:
DataException

getDoubleMax

public double getDoubleMax()
                    throws DataException
Throws:
DataException

getStartIndex

public long getStartIndex()
                   throws UnsupportedOperation
Throws:
UnsupportedOperation

getLastIndex

public long getLastIndex()
                  throws UnsupportedOperation
Throws:
UnsupportedOperation

computeMin

public java.lang.Object computeMin()
                            throws UnsupportedOperation
Force the computation if possible. The operation may take some time.

Throws:
UnsupportedOperation

computeMax

public java.lang.Object computeMax()
                            throws UnsupportedOperation
Throws:
UnsupportedOperation

computeStartIndex

public long computeStartIndex()
                       throws UnsupportedOperation
Throws:
UnsupportedOperation

computeLastIndex

public long computeLastIndex()
                      throws UnsupportedOperation
Throws:
UnsupportedOperation

setSlice

public void setSlice(long min,
                     long max)
Sets a region of interest in the DataSource. This is a purely informative function, but the DataSource may use this information to optimize itself on this specific range.


isComparable

public boolean isComparable()
Check if the values are comparable with each other. If they are, the sortedOrder() function tells if they are also sorted.


sortedOrder

public int sortedOrder()
Check if the values are sorted or not. This is usefull to optimize some computations (curves drawing for instance)

Returns:
0 if the values are not sorted, 1 if the values are sorted in ascending order and -1 if the values are sorted in descending order

getSortedOrder

public int getSortedOrder()
Returns:
sortedOrder

computeSortedOrder

public void computeSortedOrder()
Compute sortedOrder attribute reagarding all data source values


updateSortedOrder

public void updateSortedOrder()

getInformation

public DataInfo getInformation()

getSourceDependencies

public DataSource[] getSourceDependencies()
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.


addListener

public void addListener(DataSourceListener dsl)

removeListener

public void removeListener(DataSourceListener dsl)

addEndNotificationListener

public void addEndNotificationListener(EndNotificationListener enl)

removeEndNotificationListener

public void removeEndNotificationListener(EndNotificationListener enl)

notifyListenersForValueChange

public void notifyListenersForValueChange(long minIndex,
                                          long maxIndex)

notifyListenersForIndexRangeChange

public void notifyListenersForIndexRangeChange(long startIndex,
                                               long lastIndex)

notifyListenersForInfoChange

public void notifyListenersForInfoChange(DataInfo newInfo)

notifyListenersForDataReplaced

public void notifyListenersForDataReplaced(DataSource oldData,
                                           DataSource newData)

createEmptyDataSource

protected DataSource createEmptyDataSource()
Create an empty data source with same references than current data source. A such empty data source can be replaced later when new collections have been added to pool

Returns:
an empty data source

notifyListenersForDataReplaced

public void notifyListenersForDataReplaced(DataSource newData)

notifyListenersForValueRangeChange

public void notifyListenersForValueRangeChange()

notifyListenersForOrderChange

public void notifyListenersForOrderChange(int newOrder)

notifyEndNotificationListeners

public void notifyEndNotificationListeners()
Use this method only when this data source is the referer. See class comments for EndNotificationListener. Data source collections handle the notification directly


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

isCompound

public boolean isCompound()
Checks if a data source is compound, i.e. if it provides auxiliary data sources

Returns:
true if it is compound

isAuxiliary

public boolean isAuxiliary()
Returns:
true if the data source is an auxiliary data source

getAuxiliarySources

public java.util.Collection getAuxiliarySources()
If the data source is compund return the collection of auxiliary data sources

Returns:
the auxilary data source collection or null if not a compound data source

getDataSourceInformationClass

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

Returns:
the box

getChoiceFormat

public java.text.ChoiceFormat getChoiceFormat()
This method allows you to attach a format to data source values

Returns:
datasource choiceformat