simtools.data
Class ValueProvider

java.lang.Object
  extended by simtools.data.ValueProvider
Direct Known Subclasses:
Buffer, DataSource

public abstract class ValueProvider
extends java.lang.Object

Objects implementing this interface can provide values vased on an index. Useful for data sources (and their collections), buffers, etc.


Field Summary
static int ByteProvider
          Public constructor values for buffer type Default is buffer of Objects (unoptimized but generic)
static int DoubleProvider
           
static int FloatProvider
           
static int IntegerProvider
           
protected  int kind
           
static int LongProvider
           
static int ObjectProvider
           
static int ShortProvider
           
 
Constructor Summary
ValueProvider()
           
 
Method Summary
 byte getByteValue(long index)
          Optimized accessor for byte values.
 double getDoubleValue(long index)
          Optimized accessor for double values.
 float getFloatValue(long index)
          Optimized accessor for float values.
 int getIntegerValue(long index)
          Optimized accessor for int values.
 int getKind()
          The kind of this provider may be used fo optimization purpose.
 long getLongValue(long index)
          Optimized accessor for long values.
 java.lang.Object getObjectValue(long index)
          Naming compatibility function.
 short getShortValue(long index)
          Optimized accessor for short values.
abstract  java.lang.Object getValue(long index)
           
 java.lang.Class valueClass()
          Returns the more specialized superclass of all objects returned by this provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ByteProvider

public static final int ByteProvider
Public constructor values for buffer type Default is buffer of Objects (unoptimized but generic)

See Also:
Constant Field Values

ShortProvider

public static final int ShortProvider
See Also:
Constant Field Values

IntegerProvider

public static final int IntegerProvider
See Also:
Constant Field Values

LongProvider

public static final int LongProvider
See Also:
Constant Field Values

FloatProvider

public static final int FloatProvider
See Also:
Constant Field Values

DoubleProvider

public static final int DoubleProvider
See Also:
Constant Field Values

ObjectProvider

public static final int ObjectProvider
See Also:
Constant Field Values

kind

protected int kind
Constructor Detail

ValueProvider

public ValueProvider()
Method Detail

getValue

public abstract java.lang.Object getValue(long index)
                                   throws DataException
Throws:
DataException

getObjectValue

public java.lang.Object getObjectValue(long index)
                                throws DataException
Naming compatibility function. Calls getValue()

Throws:
DataException

valueClass

public java.lang.Class valueClass()
Returns the more specialized superclass of all objects returned by this provider. Returns Object by default in the base implementation, subclass should specialize if possible.


getByteValue

public byte getByteValue(long index)
                  throws DataException
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.

Throws:
DataException

getShortValue

public short getShortValue(long index)
                    throws DataException
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.

Throws:
DataException

getIntegerValue

public int getIntegerValue(long index)
                    throws DataException
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.

Throws:
DataException

getLongValue

public long getLongValue(long index)
                  throws DataException
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.

Throws:
DataException

getFloatValue

public float getFloatValue(long index)
                    throws DataException
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.

Throws:
DataException

getDoubleValue

public double getDoubleValue(long index)
                      throws DataException
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.

Throws:
DataException

getKind

public int getKind()
The kind of this provider may be used fo optimization purpose. This is just an indication for getXXXValue typed functions.

Returns:
the kind of this provider