Data Request Broker
2-3-release

fr.gael.drb.value
Class AbstractNumericArray

java.lang.Object
  extended by fr.gael.drb.value.AbstractValueArray
      extended by fr.gael.drb.value.AbstractNumericArray
All Implemented Interfaces:
DrbItem, DrbSequence, Comparison, NumericArray, Value, ValueArray, ValueFormat, Serializable
Direct Known Subclasses:
ByteArray, DoubleArray, FloatArray, IntArray, LongArray, ShortArray, UnsignedByteArray, UnsignedIntArray, UnsignedLongArray, UnsignedShortArray

public abstract class AbstractNumericArray
extends AbstractValueArray
implements NumericArray, ValueFormat

Generic numeric array wrapper.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface fr.gael.drb.value.Value
ARRAY_ID, BINARY_ID, BINARY_INTEGER_ID, BOOLEAN_ID, BYTE_ID, DATE_ID, DATE_TIME_ID, DAY_ID, DAY_TIME_DURATION_ID, DECIMAL_ID, DOUBLE_ID, DURATION_ID, FLOAT_ID, INT_ID, INTEGER_ID, LONG_ID, MONTH_DAY_ID, MONTH_ID, NULL_ID, NUMERIC_ID, OTHER_ID, SHORT_ID, STRING_ID, TIME_ID, UNKNOWN_ID, UNSIGNED_BYTE_ID, UNSIGNED_INT_ID, UNSIGNED_LONG_ID, UNSIGNED_SHORT_ID, YEAR_ID, YEAR_MONTH_DURATION_ID, YEAR_MONTH_ID
 
Fields inherited from interface fr.gael.drb.DrbItem
ATTRIBUTE_ITEM, NODE_ITEM, UNDEFINED_ITEM, VALUE_ITEM
 
Constructor Summary
AbstractNumericArray()
           
 
Method Summary
 void assign(int index, boolean value)
          Assign a value to an index
 void assign(int index, byte value)
          Assign a value to an index
 void assign(int index, double value)
          Assign a value to an index
 void assign(int index, float value)
          Assign a value to an index
 void assign(int index, int value)
          Assign a value to an index
 void assign(int index, long value)
          Assign a value to an index
 void assign(int index, short value)
          Assign a value to an index
 boolean booleanValue(int index)
          Returns this value as a boolean.
 boolean[] booleanValues()
          Returns this value as a boolean.
 byte byteValue(int index)
          Returns this value as a byte (signed 8 bits).
 byte[] byteValues()
          Returns this value as a byte (signed 8 bits).
 ValueArray convertArrayTo(int array_type)
          Convert the array values into the specified type.
 double doubleValue(int index)
          Returns this value as a double
 double[] doubleValues()
          Returns the item values as double (signed 64 bits IEEE 754).
 float floatValue(int index)
          Returns this value as a float (signed 32 bits IEEE 754).
 float[] floatValues()
          Returns the item values as float (signed 32 bits IEEE 754).
 int getArrayType()
          Returns the Array type
abstract  Object getData()
          Returns the underlying object for optimization.
 byte[] getFormattedBuffer()
          Return a byte buffer containing the value in a fixed format.
 String getFormattedString(int length)
          Return a string containing the value with a fixed format.
 int getItemType()
          A code that identifies the value items.
 String getName()
          Name of the item.
 String getNamespaceURI()
          Get namespace URI.
 int getType()
          The type identifier of the value.
 Value getValue()
          The value of the item.
 int intValue(int index)
          Returns this value as an integer (signed 32 bits).
 int[] intValues()
          Returns this value as an integer (signed 32 bits).
 long longValue(int index)
          Returns this value as a long integer (signed 64 bits).
 long[] longValues()
          Returns this value as a long integer (signed 64 bits).
 void rename(String name)
          Changes the name of the item.
 void setNamespaceURI(String namespace_uri)
          Sets a namespace resource identifier.
 Value setValue(Value value)
          Changes the value of the item.
 short shortValue(int index)
          Returns this value as a short integer (signed 16 bits).
 short[] shortValues()
          Returns this value as a short integer (signed 16 bits).
 Numeric toNumeric()
          Convert the value into the numeric type.
 
Methods inherited from class fr.gael.drb.value.AbstractValueArray
addItem, atomize, compareTo, convertTo, getItem, getLength, main, removeItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.gael.drb.value.ValueArray
assign, getElement, length
 
Methods inherited from interface fr.gael.drb.value.Value
assign, convertTo, getPriority, getType
 
Methods inherited from interface fr.gael.drb.DrbItem
getItemType, getName, getNamespaceURI, getValue, rename, setNamespaceURI, setValue
 
Methods inherited from interface fr.gael.drb.DrbSequence
addItem, atomize, getItem, getLength, removeItem
 
Methods inherited from interface fr.gael.drb.value.Comparison
compareTo
 

Constructor Detail

AbstractNumericArray

public AbstractNumericArray()
Method Detail

getData

public abstract Object getData()
Returns the underlying object for optimization.

Returns:
a backing array.

getFormattedString

public String getFormattedString(int length)
Return a string containing the value with a fixed format.

Specified by:
getFormattedString in interface ValueFormat
Parameters:
length - The expected length of the output string
Returns:
The formatted string.

getFormattedBuffer

public byte[] getFormattedBuffer()
Return a byte buffer containing the value in a fixed format.

Specified by:
getFormattedBuffer in interface ValueFormat
Returns:
The formatted buffer.

getArrayType

public int getArrayType()
Returns the Array type

Specified by:
getArrayType in interface ValueArray
Returns:
the array type as an int

convertArrayTo

public final ValueArray convertArrayTo(int array_type)
                                throws ClassCastException
Convert the array values into the specified type.

Overrides:
convertArrayTo in class AbstractValueArray
Parameters:
array_type - The target element type.
Returns:
The converted value.
Throws:
ClassCastException - if the conversion is impossible.

booleanValues

public boolean[] booleanValues()
Returns this value as a boolean.

Returns:
the numeric value represented by this object after conversion to type byte.

byteValues

public byte[] byteValues()
Returns this value as a byte (signed 8 bits). The conversion may result in a loss of precision.

Returns:
the numeric value represented by this object after conversion to type byte.

shortValues

public short[] shortValues()
Returns this value as a short integer (signed 16 bits). The conversion may result in a loss of precision.

Returns:
the numeric value represented by this object after conversion to type short.

intValues

public int[] intValues()
Returns this value as an integer (signed 32 bits). The conversion may result in a loss of precision.

Returns:
the numeric value represented by this object after conversion to type int.

longValues

public long[] longValues()
Returns this value as a long integer (signed 64 bits). The conversion may result in a loss of precision.

Returns:
the numeric value represented by this object after conversion to type long.

floatValues

public float[] floatValues()
Returns the item values as float (signed 32 bits IEEE 754). The conversion may result in a loss of precision.

Returns:
the numeric values represented by this object after conversion to type float.

doubleValues

public double[] doubleValues()
Returns the item values as double (signed 64 bits IEEE 754). The conversion may result in a loss of precision.

Returns:
the numeric values represented by this object after conversion to type double.

booleanValue

public boolean booleanValue(int index)
Returns this value as a boolean.

Specified by:
booleanValue in interface NumericArray
Parameters:
index - position where to retrieve the value.
Returns:
the numeric value represented by this object after conversion to type boolean.

byteValue

public byte byteValue(int index)
Returns this value as a byte (signed 8 bits).

Specified by:
byteValue in interface NumericArray
Parameters:
index - position where to retrieve the value.
Returns:
the numeric value represented by this object after conversion to type byte.

intValue

public int intValue(int index)
Returns this value as an integer (signed 32 bits). The conversion may result in a loss of precision.

Specified by:
intValue in interface NumericArray
Parameters:
index - position where to retrieve the value.
Returns:
the numeric value represented by this object after conversion to type int.

longValue

public long longValue(int index)
Returns this value as a long integer (signed 64 bits). The conversion may result in a loss of precision.

Specified by:
longValue in interface NumericArray
Parameters:
index - position where to retrieve the value.
Returns:
the numeric value represented by this object after conversion to type long.

shortValue

public short shortValue(int index)
Returns this value as a short integer (signed 16 bits). The conversion may result in a loss of precision.

Specified by:
shortValue in interface NumericArray
Parameters:
index - position where to retrieve the value.
Returns:
the numeric value represented by this object after conversion to type short.

floatValue

public float floatValue(int index)
Returns this value as a float (signed 32 bits IEEE 754).

Specified by:
floatValue in interface NumericArray
Parameters:
index - position where to retrieve the value.
Returns:
the numeric value represented by this object after conversion to type float.

doubleValue

public double doubleValue(int index)
Returns this value as a double

Specified by:
doubleValue in interface NumericArray
Parameters:
index - position where to retrieve the value.
Returns:
the numeric value represented by this object after conversion

assign

public void assign(int index,
                   boolean value)
Assign a value to an index

Specified by:
assign in interface NumericArray
Parameters:
index - position where to insert the value.
value - value to assign as a double.

assign

public void assign(int index,
                   byte value)
Assign a value to an index

Specified by:
assign in interface NumericArray
Parameters:
index - position where to insert the value.
value - value to assign as a double.

assign

public void assign(int index,
                   int value)
Assign a value to an index

Specified by:
assign in interface NumericArray
Parameters:
index - position where to insert the value.
value - value to assign as a double.

assign

public void assign(int index,
                   short value)
Assign a value to an index

Specified by:
assign in interface NumericArray
Parameters:
index - position where to insert the value.
value - value to assign as a double.

assign

public void assign(int index,
                   long value)
Assign a value to an index

Specified by:
assign in interface NumericArray
Parameters:
index - position where to insert the value.
value - value to assign as a double.

assign

public void assign(int index,
                   float value)
Assign a value to an index

Specified by:
assign in interface NumericArray
Parameters:
index - position where to insert the value.
value - value to assign as a double.

assign

public void assign(int index,
                   double value)
Assign a value to an index

Specified by:
assign in interface NumericArray
Parameters:
index - position where to insert the value.
value - value to assign as a double.

getItemType

public int getItemType()
A code that identifies the value items.

Specified by:
getItemType in interface DrbItem
Returns:
The code of value items.

getName

public String getName()
Name of the item. This method always returns null.

Specified by:
getName in interface DrbItem
Returns:
null

rename

public void rename(String name)
            throws NullPointerException,
                   UnsupportedOperationException
Changes the name of the item. This method always throw an UnsupportedOperationException.

Specified by:
rename in interface DrbItem
Parameters:
name - Reference to the new name.
Throws:
UnsupportedOperationException - This exception always raised because the name property is not defined for values.
NullPointerException - This exception is overriden by an UnsupportedOperationException.

getNamespaceURI

public String getNamespaceURI()
Get namespace URI. This method always returns null.

Specified by:
getNamespaceURI in interface DrbItem
Returns:
null.

setNamespaceURI

public void setNamespaceURI(String namespace_uri)
                     throws NullPointerException,
                            UnsupportedOperationException
Sets a namespace resource identifier. This method always throw an UnsupportedOperationException.

Specified by:
setNamespaceURI in interface DrbItem
Parameters:
namespace_uri - A reference to the new namespace identifier.
Throws:
UnsupportedOperationException - This exception always raised because the name property is not defined for values.
NullPointerException - This exception is overriden by an UnsupportedOperationException.

getValue

public Value getValue()
The value of the item. The value is expressed according to one of the types supported by the fr.gael.drb.value package. Generally these types correspond to primitive types (e.g. integer, floatting points, etc.) or very low level types (e.g. string, date, etc.). On the contrary to DOM implementation all the types are allowed even the arrays, date etc. Only the Value.NULL_ID type is forbidden.

Specified by:
getValue in interface DrbItem
Returns:
The value of the attribute.

setValue

public Value setValue(Value value)
               throws NullPointerException,
                      ClassCastException,
                      UnsupportedOperationException
Changes the value of the item. This operation sets a new value of the current item.The value type of the item shall be compatible with the item implementation. If the type does not match exactly it is casted to a compatible one based on the the fr.gael.drb.value capabilities. A reference to the effectivelly assigned value is returned by the operation so it is possible to check if a cast has been performed and therefore assess the accuracy of the assignement. If the cast is not possible the operation raises an UnsupportedOperationException. If the assignment is possible and the item implementation has a physical representation the value is updated in the physical source in order to persist among sessions. It therefore possible that this operation consumses an variable time.

Specified by:
setValue in interface DrbItem
Parameters:
value - The new value of the node. This value shall not be null.
Returns:
The effectivelly assigned value. The type of this value may differ from the input one.
Throws:
NullPointerException - This exception is raised when the passed reference to the value is null. This exception may be overriden by an UnsupportedOperationException.
ClassCastException - This exception is raised when the implementation has not succeeded to cast the input value in a type compatible with the current node.
UnsupportedOperationException - This exception is raised when the implementation does not support the requested assignment for any reason.

getType

public int getType()
The type identifier of the value.

Specified by:
getType in interface Value
Returns:
an identifier of the value type.

toNumeric

public Numeric toNumeric()
                  throws ClassCastException
Convert the value into the numeric type. In case of identity conversion the value itself should be returned. If the conversion is not allowed a ClassCastException is thrown.

Returns:
The converted value.
Throws:
ClassCastException - is the convertion is impossible

Data Request Broker - DRB API®
2-3-release

Copyright© 2001-2009 GAEL Consultant. All rights reserved. Use is subject to license terms .