Data Request Broker
2-3-release

fr.gael.drb.value
Class AbstractValueArray

java.lang.Object
  extended by fr.gael.drb.value.AbstractValueArray
All Implemented Interfaces:
DrbItem, DrbSequence, Comparison, Value, ValueArray, Serializable
Direct Known Subclasses:
AbstractNumericArray, BooleanArray, DefaultValueArray

public abstract class AbstractValueArray
extends Object
implements ValueArray, Comparison

Generic array value 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
AbstractValueArray()
           
 
Method Summary
 DrbSequence addItem(int index, DrbItem item)
          Inserts a item at a given position.
 ValueArray atomize()
          The atomic values of this sequence.
 int compareTo(Value value)
          Compare this array with another array.
 ValueArray convertArrayTo(int array_type)
          Convert the array values into the specified type.
 Value convertTo(int type)
          Convert the value into the specified type.
 DrbItem getItem(int index)
          Returns a specific item of the list.
 int getItemType()
          A code that identifies the value items.
 int getLength()
          The number of items in the list.
 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.
static void main(String[] args)
          Main.
 DrbSequence removeItem(int index)
          Removes an existing item.
 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.
 Numeric toNumeric()
          Convert the value into the numeric type.
 
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, getArrayType, getElement, length
 
Methods inherited from interface fr.gael.drb.value.Value
assign, getPriority, getType
 
Methods inherited from interface fr.gael.drb.DrbItem
getItemType, getName, getNamespaceURI, getValue, rename, setNamespaceURI, setValue
 

Constructor Detail

AbstractValueArray

public AbstractValueArray()
Method Detail

convertTo

public Value convertTo(int type)
                throws ClassCastException
Convert the value into the specified type. In case of identity conversion the value itself is returned. If the conversion is not allowed a ClassCastException is thrown.

Specified by:
convertTo in interface Value
Parameters:
type - The target type.
Returns:
The converted value.
Throws:
ClassCastException - the conversion is impossible

convertArrayTo

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

Parameters:
array_type - The target element type.
Returns:
The converted value.
Throws:
ClassCastException - if the conversion is impossible.

compareTo

public int compareTo(Value value)
Compare this array with another array.

Specified by:
compareTo in interface Comparison
Parameters:
value - another array.
Returns:
The returned value is :
  • negative if the values of this array are lower than another the array.
  • zero if the two array are equal and have the same size
  • positive if the values of this array are greater than another the array

The values are compared by increasing rank.

A specific case occurs when the two arrays have not the same size. In that case the result is negative if this array is the smallest and positive otherwise.


getItem

public DrbItem getItem(int index)
Returns a specific item of the list. The item is identified by its position (i.e. index or sequence number) in the list of items. The order depends on the implementation as well as from the operation that created the list. The index starts from 0 and shall not be greater or equal to the item count of the list. A null reference is returne if the provided index is outside the list bounds.

Specified by:
getItem in interface DrbSequence
Parameters:
index - The position of the item starting from and not greater or equal to the item count in the list.
Returns:
A reference to specified item or null if no such attribute.

atomize

public ValueArray atomize()
The atomic values of this sequence. The value of the node means its content. The value is expressed accoring 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.).

Specified by:
atomize in interface DrbSequence
Returns:
A reference to the values of the sequence.

getLength

public int getLength()
The number of items in the list. This number can be 0 if the list is empty but shall never be negative.

Specified by:
getLength in interface DrbSequence
Returns:
The number of items is the list.

addItem

public DrbSequence addItem(int index,
                           DrbItem item)
                    throws NullPointerException,
                           UnsupportedOperationException,
                           IndexOutOfBoundsException
Inserts a item at a given position. The passed item is inserted in the list of children at the given position The position is the expected index of the item after insertion. All the previous item from the aimed position to the end of the list are shift to the end of the new sequence (i.e. their indices are shifted up of 1). If the given index is out of the sequence bounds and therefore less than zero and greater or equal to the current number of items,the operation raises an exception. An index equal to the current number of item is allowed and the operation is therefore equivalent to an append.

Specified by:
addItem in interface DrbSequence
Parameters:
index - The expected index of the item after the insertion.
item - A reference to the item to be inserted.
Returns:
A reference to the a sequence containing the inserted node.
Throws:
NullPointerException - This exception is raised when the passed item a null reference. This exception may be overriden by an UnsupportedOperationException.
IndexOutOfBoundsException - This exception is raised when the passe index is less than zero or if it is greater or equal to the number of item in the sequence prior the call
UnsupportedOperationException - This exception is raised when the implementation does not support the requested insertion for any reason (e.g. impossible in this current specific case or in general).

removeItem

public DrbSequence removeItem(int index)
                       throws IndexOutOfBoundsException,
                              UnsupportedOperationException
Removes an existing item. The item at the given index is removed from the sequence of the current item. The item is not modified by this operation. The index of the item to be removed has to correspond to an existing item index. If the index is less than zero or greater or equal to the current number of items, an exception is thrown.

Specified by:
removeItem in interface DrbSequence
Parameters:
index - Index of the item to be removed.
Returns:
A reference to the a sequence after the removal of the item.
Throws:
IndexOutOfBoundsException - This exception is raised when the passed index is less than zero or greater or equal to the current number of children.
UnsupportedOperationException - This exception is raised when the implementation does not support the requested removal for any reason.

main

public static void main(String[] args)
Main.


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 .