simtools.data
Class DataSourceCollection

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by simtools.data.DataSourceCollection
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess
Direct Known Subclasses:
AsciiFileDataSourceCollection, DynamicDataSourceCollection, SynchronousMergeDSCollection, TimeStampedDataSourceCollection

public abstract class DataSourceCollection
extends java.util.Vector

A data source collection gathers data sources with strong interdependancy For example, all the data source values may be read from the same file. This strong inter-dependancy is highlighted by: - The delegation of CollectiveDataSource methods here - The same indexing system for all CollectiveDataSource - A common update mechanism. This is an abstract class. Default implementation handles indexing and update mechanism, but subclasses are responsible for handling values together with setting the index corresponding to those values. Two sets of methods are provided: one uses CollectiveDataSource parameters and the other uses integer = position in the vector of the corresponding CollectiveDataSource. They are of course equivalent and the first calls the second. Thus, subclasses should only implement methods with the vector-like API, not the ones with the CollectiveDataSource parameters.

See Also:
Serialized Form

Nested Class Summary
 class DataSourceCollection.Container
           
 
Field Summary
protected  Buffer[] buffers
           
protected  ListenerManager endNotificationListeners
           
protected  long lastIndex
           
protected  ListenerManager listeners
           
protected  java.util.HashMap map
          to get quickly the StreamingDataSource in the vector according to its name
protected  long startIndex
           
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DataSourceCollection()
           
 
Method Summary
 void addEndNotificationListener(EndNotificationListener enl)
           
 void addListener(DataSourceCollectionListener dscl)
           
 void attachBuffer(int i, Buffer b)
          Internal method for the buffer package only, could lead to inconsistencies if misused.
 void bufferize(Buffer b)
          Public method to put a buffer on a data source
 void bufferize(int i)
          Public method to put a buffer on a data source.
 void bufferize(int i, Buffer b)
          Public method to put a buffer on a data source
 long computeLastIndex()
           
 long computeLastIndex(int i)
           
 java.lang.Object computeMax(int i)
           
 java.lang.Object computeMin(int i)
           
 long computeStartIndex()
           
 long computeStartIndex(int i)
           
 DataSource get(java.lang.String id)
           
 byte getByteMax(int i)
           
 byte getByteMin(int i)
           
 byte getByteValue(int i, long index)
          Optimized accessor for byte values.
 java.util.Collection getCollectionContainers()
          If the data source collection is compound return the first level collection of containers used to organize the data sources
 double getDoubleMax(int i)
           
 double getDoubleMin(int i)
           
 double getDoubleValue(int i, long index)
          Optimized accessor for double values.
 float getFloatMax(int i)
           
 float getFloatMin(int i)
           
 float getFloatValue(int i, long index)
          Optimized accessor for float values.
 DataInfo getInformation()
           
 DataInfo getInformation(int i)
           
 int getIntegerMax(int i)
           
 int getIntegerMin(int i)
           
 int getIntegerValue(int i, long index)
          Optimized accessor for int values.
 int getKind(int i)
          Kind of the data source at position i, Object by default
 long getLastIndex()
           
 long getLastIndex(int i)
           
 long getLongMax(int i)
           
 long getLongMin(int i)
           
 long getLongValue(int i, long index)
          Optimized accessor for long values.
 java.lang.Object getMax(int i)
           
 java.lang.Object getMin(int i)
           
 short getShortMax(int i)
           
 short getShortMin(int i)
           
 short getShortValue(int i, long index)
          Optimized accessor for short values.
 long getStartIndex()
          Common indexation system for all members of this collection
 long getStartIndex(int i)
           
abstract  java.lang.Object getValue(int i, long index)
          Methods for subclasses to specialize
 int hashCode()
          Overrides Vector/AbstractList implementation to get a fix hashcode and be able to put and remove a collection from a HashSet for instance
 boolean isComparable(int i)
           
 boolean isCompound()
          Checks if a data source collection is compound, i.e. if it provides containers to organize the data source hierarchically
 void notifyEndNotificationListeners()
          Use this method only when this data source collection is the referer.
protected  void notifyListenersForCollectionRemoved()
           
protected  void notifyListenersForDataSourceAdded(DataSource ds)
           
protected  void notifyListenersForDataSourceRemoved(DataSource ds)
           
 void notifyListenersForInfoChange(DataInfo newInfo)
           
 void removeAllElements()
           
 void removeEndNotificationListener(EndNotificationListener enl)
           
 void removeListener(DataSourceCollectionListener dscl)
           
 void setSlice(long min, long max)
           
 int sortedOrder(int i)
           
 java.lang.Class valueClass(int i)
          Returns the more specialized superclass of all objects returned by the i-th data source.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

listeners

protected ListenerManager listeners

endNotificationListeners

protected ListenerManager endNotificationListeners

startIndex

protected long startIndex

lastIndex

protected long lastIndex

buffers

protected Buffer[] buffers

map

protected java.util.HashMap map
to get quickly the StreamingDataSource in the vector according to its name

Constructor Detail

DataSourceCollection

public DataSourceCollection()
Method Detail

getStartIndex

public long getStartIndex()
                   throws UnsupportedOperation
Common indexation system for all members of this collection

Throws:
UnsupportedOperation

getLastIndex

public long getLastIndex()
                  throws UnsupportedOperation
Throws:
UnsupportedOperation

computeStartIndex

public long computeStartIndex()
                       throws UnsupportedOperation
Throws:
UnsupportedOperation

computeLastIndex

public long computeLastIndex()
                      throws UnsupportedOperation
Throws:
UnsupportedOperation

getStartIndex

public long getStartIndex(int i)
                   throws UnsupportedOperation
Throws:
UnsupportedOperation

getLastIndex

public long getLastIndex(int i)
                  throws UnsupportedOperation
Throws:
UnsupportedOperation

computeStartIndex

public long computeStartIndex(int i)
                       throws UnsupportedOperation
Throws:
UnsupportedOperation

computeLastIndex

public long computeLastIndex(int i)
                      throws UnsupportedOperation
Throws:
UnsupportedOperation

setSlice

public void setSlice(long min,
                     long max)

getInformation

public DataInfo getInformation()

getKind

public int getKind(int i)
Kind of the data source at position i, Object by default

Returns:
the i-th data source kind

valueClass

public java.lang.Class valueClass(int i)
Returns the more specialized superclass of all objects returned by the i-th data source. Returns Object by default in the base implementation, subclass should specialize if possible.


get

public DataSource get(java.lang.String id)
Parameters:
id -
Returns:
data source related to a string id

attachBuffer

public void attachBuffer(int i,
                         Buffer b)
Internal method for the buffer package only, could lead to inconsistencies if misused. User classes should use bufferize instead.


bufferize

public void bufferize(int i)
               throws UnsupportedOperation
Public method to put a buffer on a data source. This function uses the default buffer for this collection.

Parameters:
i - The position of the datasource to bufferize
Throws:
UnsupportedOperation

bufferize

public void bufferize(int i,
                      Buffer b)
               throws UnsupportedOperation
Public method to put a buffer on a data source

Parameters:
i - The position of the datasource to bufferize
b - The buffer to use. It must have been created using the datasource at position i, or a null provider (in which case, the datasource at position i will be used automatically). An UnsupportedOperation exception is thrown otherwise.
Throws:
UnsupportedOperation

bufferize

public void bufferize(Buffer b)
               throws UnsupportedOperation
Public method to put a buffer on a data source

Parameters:
b - The buffer to use. It must have been created using a null provider. The buffer will then be cloned and applied to all datasources using the bufferize(int,Buffer) function.
Throws:
UnsupportedOperation

getValue

public abstract java.lang.Object getValue(int i,
                                          long index)
                                   throws DataException
Methods for subclasses to specialize

Throws:
DataException

getByteValue

public byte getByteValue(int i,
                         long index)
                  throws DataException
Optimized accessor for byte values. Works the same way as provider functions.

Throws:
DataException

getShortValue

public short getShortValue(int i,
                           long index)
                    throws DataException
Optimized accessor for short values. Works the same way as provider functions.

Throws:
DataException

getIntegerValue

public int getIntegerValue(int i,
                           long index)
                    throws DataException
Optimized accessor for int values. Works the same way as provider functions.

Throws:
DataException

getLongValue

public long getLongValue(int i,
                         long index)
                  throws DataException
Optimized accessor for long values. Works the same way as provider functions.

Throws:
DataException

getFloatValue

public float getFloatValue(int i,
                           long index)
                    throws DataException
Optimized accessor for float values. Works the same way as provider functions.

Throws:
DataException

getDoubleValue

public double getDoubleValue(int i,
                             long index)
                      throws DataException
Optimized accessor for double values. Works the same way as provider functions.

Throws:
DataException

getInformation

public DataInfo getInformation(int i)

getMin

public java.lang.Object getMin(int i)
                        throws UnsupportedOperation
Throws:
UnsupportedOperation

getMax

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

getByteMin

public byte getByteMin(int i)
                throws DataException
Throws:
DataException

getByteMax

public byte getByteMax(int i)
                throws DataException
Throws:
DataException

getShortMin

public short getShortMin(int i)
                  throws DataException
Throws:
DataException

getShortMax

public short getShortMax(int i)
                  throws DataException
Throws:
DataException

getIntegerMin

public int getIntegerMin(int i)
                  throws DataException
Throws:
DataException

getIntegerMax

public int getIntegerMax(int i)
                  throws DataException
Throws:
DataException

getLongMin

public long getLongMin(int i)
                throws DataException
Throws:
DataException

getLongMax

public long getLongMax(int i)
                throws DataException
Throws:
DataException

getFloatMin

public float getFloatMin(int i)
                  throws DataException
Throws:
DataException

getFloatMax

public float getFloatMax(int i)
                  throws DataException
Throws:
DataException

getDoubleMin

public double getDoubleMin(int i)
                    throws DataException
Throws:
DataException

getDoubleMax

public double getDoubleMax(int i)
                    throws DataException
Throws:
DataException

computeMin

public java.lang.Object computeMin(int i)
                            throws UnsupportedOperation
Throws:
UnsupportedOperation

computeMax

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

sortedOrder

public int sortedOrder(int i)

isComparable

public boolean isComparable(int i)

addListener

public void addListener(DataSourceCollectionListener dscl)

removeListener

public void removeListener(DataSourceCollectionListener dscl)

addEndNotificationListener

public void addEndNotificationListener(EndNotificationListener enl)

removeEndNotificationListener

public void removeEndNotificationListener(EndNotificationListener enl)

notifyListenersForInfoChange

public void notifyListenersForInfoChange(DataInfo newInfo)

notifyListenersForDataSourceAdded

protected void notifyListenersForDataSourceAdded(DataSource ds)

notifyListenersForDataSourceRemoved

protected void notifyListenersForDataSourceRemoved(DataSource ds)

notifyListenersForCollectionRemoved

protected void notifyListenersForCollectionRemoved()

removeAllElements

public void removeAllElements()
Overrides:
removeAllElements in class java.util.Vector

notifyEndNotificationListeners

public void notifyEndNotificationListeners()
Use this method only when this data source collection is the referer. See class comments for EndNotificationListener. Listeners for data sources in this collection will also be notified, but only once (if a listener listens to more than one data source in this collection, it is notified once).


hashCode

public int hashCode()
Overrides Vector/AbstractList implementation to get a fix hashcode and be able to put and remove a collection from a HashSet for instance

Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Overrides:
hashCode in class java.util.Vector

isCompound

public boolean isCompound()
Checks if a data source collection is compound, i.e. if it provides containers to organize the data source hierarchically

Returns:
true if it is compound

getCollectionContainers

public java.util.Collection getCollectionContainers()
If the data source collection is compound return the first level collection of containers used to organize the data sources

Returns:
the first level collection of containers or null