Data Request Broker
2-3-release

fr.gael.drb.value
Class UnsignedByte

java.lang.Object
  extended by fr.gael.drb.value.UnsignedByte
All Implemented Interfaces:
DrbItem, Arithmetic, Comparison, Logic, Numeric, Sumable, Value, ValueFormat, Serializable, Comparable

public class UnsignedByte
extends Object
implements ValueFormat

The UnsignedByte class is a generic wrapper for unsigned byte values.

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
UnsignedByte(byte v)
          Constructs a Byte object initialized to the specified byte value.
UnsignedByte(byte[] val)
          Constructs a UnsignedByte object initialized to the specified integer buffer.
UnsignedByte(byte[] val, int off)
          Constructs a UnsignedByte object initialized to the specified integer buffer.
UnsignedByte(int v)
          Allocates a Byte object representing the value argument.
 
Method Summary
 Value add(Value x)
          Adds the current Value to the current one
 boolean and(Value x)
          Compute a logical AND.
 void assign(boolean value)
          Assign a boolean value.
 void assign(byte value)
          Assign a byte value.
 void assign(double value)
          Assign a double value.
 void assign(float value)
          Assign a float value.
 void assign(int value)
          Assign an int value.
 void assign(long value)
          Assign a long value.
 void assign(short value)
          Assign short value.
 void assign(Value v)
          assign a new Value to the current one.
 boolean booleanValue()
          gives the logical value of this Value.
 byte byteValue()
          Convert the value into byte (signed 8 bits).
 int compareTo(Object obj)
          Compares this object with the specified object for order.
 int compareTo(Value x)
          Compares the current Value to the given one
 Value convertTo(int type)
          Convert this Byte value into the specified type.
protected  BigDecimal decimalValue()
          Returns this value as a BigDecimal.
 Value divide(Value x)
          Divides the current Value by the current one
 double doubleValue()
          Convert the value into float (signed 64 bits IEEE 754).
 boolean equals(Object obj)
          Indicates whether this value is "equal to" to another value.
 float floatValue()
          Convert the value into float (signed 32 bits IEEE 754).
 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 getPriority()
          Returns the current priority.
 int getType()
          Returns the current type.
 Value getValue()
          The value of the item.
 int hashCode()
          Returns a hash code value for the object.
protected  BigInteger integerValue()
          Returns this value as a BigInteger.
 int intValue()
          Convert the value into integer (signed 32 bits).
 long longValue()
          Convert the value into long integer (signed 64 bits).
static void main(String[] args)
           
 Value modulus(Value x)
          Calculates the current value modulus the given one.
 Value multiply(Value x)
          Multiplies the current Value by the current one
 boolean or(Value x)
          Compute a logical OR.
 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()
          Convert the value into short integer (signed 16 bits).
 Value sub(Value x)
          Substracts the current Value by the current one
 Numeric toNumeric()
          Convert the value into the numeric type.
 String toString()
          Returns a new String object representing the specified Byte.
 Value unaryMinus()
          unary Minus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface fr.gael.drb.DrbItem
getItemType, getName, getNamespaceURI, getValue, rename, setNamespaceURI, setValue
 

Constructor Detail

UnsignedByte

public UnsignedByte(byte v)
Constructs a Byte object initialized to the specified byte value.

Parameters:
v - the value of the Byte.

UnsignedByte

public UnsignedByte(int v)
Allocates a Byte object representing the value argument.

Parameters:
v - the value of the Byte.

UnsignedByte

public UnsignedByte(byte[] val)
Constructs a UnsignedByte object initialized to the specified integer buffer.

Parameters:
val - two's-complement binary representation of UnsignedByte. The array must contain at least one byte.

UnsignedByte

public UnsignedByte(byte[] val,
                    int off)
Constructs a UnsignedByte object initialized to the specified integer buffer.

Parameters:
val - two's-complement binary representation of UnsignedByte. The array must contain at least one byte.
off - The offset of the byte in the array.
Method Detail

toString

public String toString()
Returns a new String object representing the specified Byte.

Overrides:
toString in class Object
Returns:
a string representation of the object.

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.

getType

public final int getType()
Returns the current type.

Specified by:
getType in interface Value
Returns:
the current type.

getPriority

public final int getPriority()
Returns the current priority.

Specified by:
getPriority in interface Value
Returns:
the current priority.

convertTo

public final Value convertTo(int type)
                      throws ClassCastException
Convert this Byte value into the specified type. In case of identity conversion the value itself should be 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 - if the conversion is impossible

assign

public void assign(Value v)
assign a new Value to the current one.

Specified by:
assign in interface Value
Parameters:
v - the new Value

unaryMinus

public Value unaryMinus()
unary Minus

Specified by:
unaryMinus in interface Arithmetic
Returns:
the value

add

public final Value add(Value x)
Adds the current Value to the current one

Specified by:
add in interface Sumable
Parameters:
x - the Value to add to
Returns:
the current Value added by the current one

sub

public final Value sub(Value x)
Substracts the current Value by the current one

Specified by:
sub in interface Arithmetic
Parameters:
x - the Value to substract to
Returns:
the current Value substracted by the current one

multiply

public final Value multiply(Value x)
Multiplies the current Value by the current one

Specified by:
multiply in interface Arithmetic
Parameters:
x - the Value to multiply by
Returns:
the current Value multiplied by the current one

divide

public final Value divide(Value x)
Divides the current Value by the current one

Specified by:
divide in interface Arithmetic
Parameters:
x - the Value to divide by
Returns:
the current Value divided by the current one

modulus

public final Value modulus(Value x)
Calculates the current value modulus the given one.

Specified by:
modulus in interface Arithmetic
Parameters:
x - the Value to modulate by
Returns:
the current value modulus the given one

compareTo

public int compareTo(Value x)
Compares the current Value to the given one

Specified by:
compareTo in interface Comparison
Parameters:
x - the Value to compare with
Returns:
a negative integer, zero, or a positive integer as the argument is less than, equal to, or greater than the current Value

booleanValue

public final boolean booleanValue()
gives the logical value of this Value.

Specified by:
booleanValue in interface Logic
Returns:
the logical value of this Value.

byteValue

public final byte byteValue()
Convert the value into byte (signed 8 bits). The conversion may result in a loss of precision.

Specified by:
byteValue in interface Numeric
Returns:
an equivalent byte value.

intValue

public final int intValue()
Convert the value into integer (signed 32 bits). The conversion may result in a loss of precision.

Specified by:
intValue in interface Numeric
Returns:
an equivalent integer value.

longValue

public final long longValue()
Convert the value into long integer (signed 64 bits). The conversion may result in a loss of precision.

Specified by:
longValue in interface Numeric
Returns:
an equivalent long integer value.

shortValue

public final short shortValue()
Convert the value into short integer (signed 16 bits). The conversion may result in a loss of precision.

Specified by:
shortValue in interface Numeric
Returns:
an equivalent short integer value.

floatValue

public final float floatValue()
Convert the value into float (signed 32 bits IEEE 754). The conversion may result in a loss of precision.

Specified by:
floatValue in interface Numeric
Returns:
an equivalent float value.

doubleValue

public final double doubleValue()
Convert the value into float (signed 64 bits IEEE 754). The conversion may result in a loss of precision.

Specified by:
doubleValue in interface Numeric
Returns:
an equivalent double float value.

assign

public final void assign(boolean value)
Assign a boolean value.

Specified by:
assign in interface Numeric
Parameters:
value - another value. The conversion may result in a loss of precision.

assign

public final void assign(byte value)
Assign a byte value.

Specified by:
assign in interface Numeric
Parameters:
value - another value. The conversion may result in a loss of precision.

assign

public final void assign(int value)
Assign an int value.

Specified by:
assign in interface Numeric
Parameters:
value - another value. The conversion may result in a loss of precision.

assign

public final void assign(short value)
Assign short value.

Specified by:
assign in interface Numeric
Parameters:
value - another value. The conversion may result in a loss of precision.

assign

public final void assign(long value)
Assign a long value.

Specified by:
assign in interface Numeric
Parameters:
value - another value. The conversion may result in a loss of precision.

assign

public final void assign(float value)
Assign a float value.

Specified by:
assign in interface Numeric
Parameters:
value - another value. The conversion may result in a loss of precision.

assign

public final void assign(double value)
Assign a double value.

Specified by:
assign in interface Numeric
Parameters:
value - another value. The conversion may result in a loss of precision.

main

public static void main(String[] args)
Parameters:
args - the given arguments in the commad line

equals

public boolean equals(Object obj)
Indicates whether this value is "equal to" to another value. See Object.equals() for the general contract of this method.

Overrides:
equals in class Object
Parameters:
obj - another value.
Returns:
true if this object is the same as the obj argument

hashCode

public int hashCode()
Returns a hash code value for the object. See Object.hashCode() for the general contract of this method.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.

compareTo

public int compareTo(Object obj)
Compares this object with the specified object for order. See Comparable.compareTo() for the general contract of this method.

Specified by:
compareTo in interface Comparable
Parameters:
obj - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

toNumeric

public final 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

integerValue

protected BigInteger integerValue()
Returns this value as a BigInteger. The conversion may result in a loss of precision.

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

decimalValue

protected BigDecimal decimalValue()
Returns this value as a BigDecimal. The conversion may result in a loss of precision.

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

and

public final boolean and(Value x)
Compute a logical AND.

Specified by:
and in interface Logic
Parameters:
x - another value.
Returns:
logical AND of the two values.

or

public final boolean or(Value x)
Compute a logical OR.

Specified by:
or in interface Logic
Parameters:
x - another value.
Returns:
logical OR of the two values.

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.

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

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