simtools.data
Class DynamicDataSourceCollection

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
                  extended by simtools.data.DynamicDataSourceCollection
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess
Direct Known Subclasses:
DataSourceCollectionAnimator, JSMergeCollectionPlugin.TestMergedCollection1, JSMergeCollectionPlugin.TestMergedCollection2, RandomDataSourceCollection, SocketDataSourceCollection

public class DynamicDataSourceCollection
extends DataSourceCollection

See Also:
Serialized Form

Nested Class Summary
protected  class DynamicDataSourceCollection.SourceInfo
          This class contains info necessary to handle the data sources.
 
Nested classes/interfaces inherited from class simtools.data.DataSourceCollection
DataSourceCollection.Container
 
Field Summary
protected  DataInfo ourInfo
           
protected  DynamicDataSourceCollection.SourceInfo[] sourceInfo
           
 
Fields inherited from class simtools.data.DataSourceCollection
buffers, endNotificationListeners, lastIndex, listeners, map, startIndex
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DynamicDataSourceCollection()
           
 
Method Summary
 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
protected  void changeDataSourceInfo(DataSource ds, DataInfo di)
          Change the information relative to a datasource.
protected  void changeInfo(DataInfo di)
          Change our own information.
 long computeLastIndex(int i)
           
 java.lang.Object computeMax(int i)
           
 java.lang.Object computeMin(int i)
           
 long computeStartIndex(int i)
           
protected  DataSource createDataSource(DataInfo info)
           
protected  DataSource createDataSource(DataInfo info, int kind)
          Add a data source with the given info.
 byte getByteMax(int i)
           
 byte getByteMin(int i)
           
 double getDoubleMax(int i)
           
 double getDoubleMin(int i)
           
 float getFloatMax(int i)
           
 float getFloatMin(int i)
           
 DataInfo getInformation()
           
 DataInfo getInformation(int i)
          Other functions have a reasonable default implementation
 int getIntegerMax(int i)
           
 int getIntegerMin(int i)
           
 int getKind(int i)
          Kind of the data source at position i, Object by default
 long getLastIndex(int i)
           
 long getLongMax(int i)
           
 long getLongMin(int i)
           
 java.lang.Object getMax(int i)
           
 java.lang.Object getMin(int i)
           
 short getShortMax(int i)
           
 short getShortMin(int i)
           
 long getStartIndex(int i)
           
 java.lang.Object getValue(int i, long index)
          Methods for subclasses to specialize
 boolean isComparable(int i)
           
protected  void registerNewValues()
          Call this function once you have set up all the values with setValue.
protected  void removeDataSource(DataSource ds)
           
protected  void removeDataSource(int i)
          Remove the given data source.
protected  void setByteValue(int dsnum, byte v)
          Sets the value of the Datasource numbered dsnum to the byte v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues().
protected  void setDoubleValue(int dsnum, double v)
          Sets the value of the Datasource numbered dsnum to the double v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues().
protected  void setFloatValue(int dsnum, float v)
          Sets the value of the Datasource numbered dsnum to the float v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues().
protected  void setIntegerValue(int dsnum, int v)
          Sets the value of the Datasource numbered dsnum to the int v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues().
protected  void setLongValue(int dsnum, long v)
          Sets the value of the Datasource numbered dsnum to the long v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues().
protected  void setObjectValue(int dsnum, java.lang.Object v)
          Sets the value of the Datasource numbered dsnum to the Object v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues().
protected  void setShortValue(int dsnum, short v)
          Sets the value of the Datasource numbered dsnum to the short v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues().
 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 simtools.data.DataSourceCollection
addEndNotificationListener, addListener, attachBuffer, computeLastIndex, computeStartIndex, get, getByteValue, getCollectionContainers, getDoubleValue, getFloatValue, getIntegerValue, getLastIndex, getLongValue, getShortValue, getStartIndex, hashCode, isCompound, notifyEndNotificationListeners, notifyListenersForCollectionRemoved, notifyListenersForDataSourceAdded, notifyListenersForDataSourceRemoved, notifyListenersForInfoChange, removeAllElements, removeEndNotificationListener, removeListener, setSlice, sortedOrder
 
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

sourceInfo

protected DynamicDataSourceCollection.SourceInfo[] sourceInfo

ourInfo

protected DataInfo ourInfo
Constructor Detail

DynamicDataSourceCollection

public DynamicDataSourceCollection()
Method Detail

bufferize

public void bufferize(Buffer b)
               throws UnsupportedOperation
Description copied from class: DataSourceCollection
Public method to put a buffer on a data source

Overrides:
bufferize in class DataSourceCollection
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

bufferize

public void bufferize(int i,
                      Buffer b)
               throws UnsupportedOperation
Description copied from class: DataSourceCollection
Public method to put a buffer on a data source

Overrides:
bufferize in class DataSourceCollection
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(int i)
               throws UnsupportedOperation
Description copied from class: DataSourceCollection
Public method to put a buffer on a data source. This function uses the default buffer for this collection.

Overrides:
bufferize in class DataSourceCollection
Parameters:
i - The position of the datasource to bufferize
Throws:
UnsupportedOperation

getInformation

public DataInfo getInformation(int i)
Other functions have a reasonable default implementation

Overrides:
getInformation in class DataSourceCollection

getMin

public java.lang.Object getMin(int i)
                        throws UnsupportedOperation
Overrides:
getMin in class DataSourceCollection
Throws:
UnsupportedOperation

getMax

public java.lang.Object getMax(int i)
                        throws UnsupportedOperation
Overrides:
getMax in class DataSourceCollection
Throws:
UnsupportedOperation

getByteMin

public byte getByteMin(int i)
                throws DataException
Overrides:
getByteMin in class DataSourceCollection
Throws:
DataException

getByteMax

public byte getByteMax(int i)
                throws DataException
Overrides:
getByteMax in class DataSourceCollection
Throws:
DataException

getShortMin

public short getShortMin(int i)
                  throws DataException
Overrides:
getShortMin in class DataSourceCollection
Throws:
DataException

getShortMax

public short getShortMax(int i)
                  throws DataException
Overrides:
getShortMax in class DataSourceCollection
Throws:
DataException

getIntegerMin

public int getIntegerMin(int i)
                  throws DataException
Overrides:
getIntegerMin in class DataSourceCollection
Throws:
DataException

getIntegerMax

public int getIntegerMax(int i)
                  throws DataException
Overrides:
getIntegerMax in class DataSourceCollection
Throws:
DataException

getLongMin

public long getLongMin(int i)
                throws DataException
Overrides:
getLongMin in class DataSourceCollection
Throws:
DataException

getLongMax

public long getLongMax(int i)
                throws DataException
Overrides:
getLongMax in class DataSourceCollection
Throws:
DataException

getFloatMin

public float getFloatMin(int i)
                  throws DataException
Overrides:
getFloatMin in class DataSourceCollection
Throws:
DataException

getFloatMax

public float getFloatMax(int i)
                  throws DataException
Overrides:
getFloatMax in class DataSourceCollection
Throws:
DataException

getDoubleMin

public double getDoubleMin(int i)
                    throws DataException
Overrides:
getDoubleMin in class DataSourceCollection
Throws:
DataException

getDoubleMax

public double getDoubleMax(int i)
                    throws DataException
Overrides:
getDoubleMax in class DataSourceCollection
Throws:
DataException

computeMin

public java.lang.Object computeMin(int i)
                            throws UnsupportedOperation
Overrides:
computeMin in class DataSourceCollection
Throws:
UnsupportedOperation

computeMax

public java.lang.Object computeMax(int i)
                            throws UnsupportedOperation
Overrides:
computeMax in class DataSourceCollection
Throws:
UnsupportedOperation

isComparable

public boolean isComparable(int i)
Overrides:
isComparable in class DataSourceCollection

getStartIndex

public long getStartIndex(int i)
Overrides:
getStartIndex in class DataSourceCollection

getLastIndex

public long getLastIndex(int i)
Overrides:
getLastIndex in class DataSourceCollection

computeStartIndex

public long computeStartIndex(int i)
Overrides:
computeStartIndex in class DataSourceCollection

computeLastIndex

public long computeLastIndex(int i)
Overrides:
computeLastIndex in class DataSourceCollection

createDataSource

protected DataSource createDataSource(DataInfo info)

createDataSource

protected DataSource createDataSource(DataInfo info,
                                      int kind)
Add a data source with the given info. Make sure you call this function before calling setValue, or just after calling registerNewValues() and before setting the values for the next round.

Parameters:
info - Any information that will describe the data source, null is possible but not recommended.
kind - the data source kind, see ValueProvider. Object is default.
Returns:
DataSource

removeDataSource

protected void removeDataSource(int i)
Remove the given data source. Make sure you call this function before calling setValue, or just after calling registerNewValues() and before setting the values for the next round.

Parameters:
ds - The data source to remove

removeDataSource

protected void removeDataSource(DataSource ds)

changeDataSourceInfo

protected void changeDataSourceInfo(DataSource ds,
                                    DataInfo di)
Change the information relative to a datasource. May be called any time, and will notify the data source listeners.


changeInfo

protected void changeInfo(DataInfo di)
Change our own information. May be called any time, and will notify the our listeners.


setByteValue

protected void setByteValue(int dsnum,
                            byte v)
Sets the value of the Datasource numbered dsnum to the byte v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues(). Only add/remove datasources before calling setValue.

Parameters:
dsnum -
v - the byte value to set

setShortValue

protected void setShortValue(int dsnum,
                             short v)
Sets the value of the Datasource numbered dsnum to the short v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues(). Only add/remove datasources before calling setValue.

Parameters:
dsnum -
v - the short value to set

setIntegerValue

protected void setIntegerValue(int dsnum,
                               int v)
Sets the value of the Datasource numbered dsnum to the int v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues(). Only add/remove datasources before calling setValue.

Parameters:
dsnum -
v - the int value to set

setLongValue

protected void setLongValue(int dsnum,
                            long v)
Sets the value of the Datasource numbered dsnum to the long v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues(). Only add/remove datasources before calling setValue.

Parameters:
dsnum -
v - the long value to set

setFloatValue

protected void setFloatValue(int dsnum,
                             float v)
Sets the value of the Datasource numbered dsnum to the float v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues(). Only add/remove datasources before calling setValue.

Parameters:
dsnum -
v - the float value to set

setDoubleValue

protected void setDoubleValue(int dsnum,
                              double v)
Sets the value of the Datasource numbered dsnum to the double v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues(). Only add/remove datasources before calling setValue.

Parameters:
dsnum -
v - the double value to set

setObjectValue

protected void setObjectValue(int dsnum,
                              java.lang.Object v)
Sets the value of the Datasource numbered dsnum to the Object v Once you call this function, you should not add/remove any datasource so long as you haven't called registerNewValues(). Only add/remove datasources before calling setValue.

Parameters:
dsnum -
v - the Object value to set

registerNewValues

protected void registerNewValues()
Call this function once you have set up all the values with setValue. Unset data sources for this round will keep their old values.

Parameters:
dsnum -
v -

getInformation

public DataInfo getInformation()
Overrides:
getInformation in class DataSourceCollection

getValue

public java.lang.Object getValue(int i,
                                 long index)
                          throws DataException
Description copied from class: DataSourceCollection
Methods for subclasses to specialize

Specified by:
getValue in class DataSourceCollection
Throws:
DataException

getKind

public int getKind(int i)
Description copied from class: DataSourceCollection
Kind of the data source at position i, Object by default

Overrides:
getKind in class DataSourceCollection
Returns:
the i-th data source kind

valueClass

public java.lang.Class valueClass(int i)
Description copied from class: DataSourceCollection
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.

Overrides:
valueClass in class DataSourceCollection