simtools.data
Class CollectiveDataSource

java.lang.Object
  extended by simtools.data.ValueProvider
      extended by simtools.data.DataSource
          extended by simtools.data.CollectiveDataSource
Direct Known Subclasses:
SynchronousMergeDSCollection.DirectSynchronousMergedDataSource, SynchronousMergeDSCollection.IndirectSynchronousMergedDataSource

public class CollectiveDataSource
extends DataSource

A collective data source is a data source part of a collection The default implementation is to delegate the data source methods to the collection.

Version:
1.0 2001
Author:
Nicolas Brodu

Field Summary
protected  DataSourceCollection collection
           
protected  int myIndex
           
 
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
CollectiveDataSource(DataSourceCollection c, int i)
           
 
Method Summary
 void addEndNotificationListener(EndNotificationListener enl)
           
 long computeLastIndex()
           
 java.lang.Object computeMax()
           
 java.lang.Object computeMin()
          Force the computation if possible.
 long computeStartIndex()
           
protected  DataSource createEmptyDataSource()
          Create an empty data source with same references than current data source.
 byte getByteMax()
           
 byte getByteMin()
           
 byte getByteValue(long index)
          Optimized accessor for byte values.
 DataSourceCollection getCollection()
           
 double getDoubleMax()
           
 double getDoubleMin()
           
 double getDoubleValue(long index)
          Optimized accessor for double values.
 float getFloatMax()
           
 float getFloatMin()
           
 float getFloatValue(long index)
          Optimized accessor for float values.
 DataInfo getInformation()
          These methods are common to the whole collection
 int getIntegerMax()
           
 int getIntegerMin()
           
 int getIntegerValue(long index)
          Optimized accessor for int values.
 int getKind()
          The kind of this provider may be used fo optimization purpose.
 long getLastIndex()
           
 long getLongMax()
           
 long getLongMin()
           
 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.
 int getPosition()
           
 short getShortMax()
           
 short getShortMin()
           
 short getShortValue(long index)
          Optimized accessor for short values.
 long getStartIndex()
           
 java.lang.Object getValue(long index)
           
 boolean isComparable()
          Check if the values are comparable with each other.
 void notifyEndNotificationListeners()
          Warning: for collective data sources, you really should think twice before calling this function, as this will notify listeners for all sources in the collection.
 void removeEndNotificationListener(EndNotificationListener enl)
           
 void setSlice(long min, long max)
          Sets a region of interest in the DataSource.
 int sortedOrder()
          Check if the values are sorted or not.
 
Methods inherited from class simtools.data.DataSource
addListener, computeSortedOrder, equals, getAuxiliarySources, getChoiceFormat, getDataSourceInformationClass, getSortedOrder, getSourceDependencies, isAuxiliary, isCompound, notifyListenersForDataReplaced, notifyListenersForDataReplaced, notifyListenersForIndexRangeChange, notifyListenersForInfoChange, notifyListenersForOrderChange, notifyListenersForValueChange, notifyListenersForValueRangeChange, removeListener, updateSortedOrder
 
Methods inherited from class simtools.data.ValueProvider
getObjectValue, valueClass
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collection

protected DataSourceCollection collection

myIndex

protected int myIndex
Constructor Detail

CollectiveDataSource

public CollectiveDataSource(DataSourceCollection c,
                            int i)
Method Detail

getCollection

public DataSourceCollection getCollection()

getPosition

public int getPosition()

getInformation

public DataInfo getInformation()
These methods are common to the whole collection

Overrides:
getInformation in class DataSource

getStartIndex

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

getLastIndex

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

setSlice

public void setSlice(long min,
                     long max)
Description copied from class: DataSource
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.

Overrides:
setSlice in class DataSource

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

getValue

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

getByteValue

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

Overrides:
getByteValue in class ValueProvider
Throws:
DataException

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

getShortValue

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

Overrides:
getShortValue in class ValueProvider
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

getIntegerValue

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

Overrides:
getIntegerValue in class ValueProvider
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

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

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

getFloatValue

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

Overrides:
getFloatValue in class ValueProvider
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

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.

Overrides:
getDoubleValue in class ValueProvider
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

computeMin

public java.lang.Object computeMin()
                            throws UnsupportedOperation
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

computeStartIndex

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

computeLastIndex

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

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

sortedOrder

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

Overrides:
sortedOrder in class DataSource
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

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

addEndNotificationListener

public void addEndNotificationListener(EndNotificationListener enl)
Overrides:
addEndNotificationListener in class DataSource

notifyEndNotificationListeners

public void notifyEndNotificationListeners()
Warning: for collective data sources, you really should think twice before calling this function, as this will notify listeners for all sources in the collection. In fact, this class delegates to the collection end-of-notification method.

Overrides:
notifyEndNotificationListeners in class DataSource

removeEndNotificationListener

public void removeEndNotificationListener(EndNotificationListener enl)
Overrides:
removeEndNotificationListener in class DataSource

createEmptyDataSource

protected DataSource createEmptyDataSource()
Description copied from class: DataSource
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

Overrides:
createEmptyDataSource in class DataSource
Returns:
an empty data source