com.simba.dsi.core.utilities
Class Variant

java.lang.Object
  extended by com.simba.dsi.core.utilities.Variant

public class Variant
extends java.lang.Object

Used as a single type to be stored in standard containers for either long, short, or string data types.


Field Summary
static int TYPE_INT16
          Constant for specifying the signed 16-bit integer variant type Must be paired with a Short object when passed into the constructor.
static int TYPE_INT32
          Constant for specifying the signed integer variant type Must be paired with an Integer object when passed into the constructor.
static int TYPE_INT64
          Constant for specifying the signed long integer variant type Must be paired with a Long object when passed into the constructor.
static int TYPE_NULL
          Constant for specifying the NULL variant type Must be paired with a null pointer when passed into the constructor.
static int TYPE_UINT16
          Constant for specifying the unsigned 16-bit integer variant type Must be paired with a Character object on construction.
static int TYPE_UINT32
          Constant for specifying the unsigned 32-bit integer variant type Must be paired with a Long object when passed into the constructor.
static int TYPE_UINT64
          Constant for specifying the unsigned 64-bit integer variant type Must be paired with a BigInteger or Long object when passed into the constructor.
static int TYPE_WSTRING
          Constant for specifying the string variant type.
static long UINT32_MAX_VALUE
          The maximum value of a UINT32.
static long UINT32_MIN_VALUE
          The minimum value of a UINT32.
static java.math.BigInteger UINT64_MAX_VALUE
          The maximum value of a UINT64.
static java.math.BigInteger UINT64_MIN_VALUE
          The minimum value of a UINT64.
 
Constructor Summary
Variant(int type, java.lang.Object value)
          Constructs a variant of the given type and value.
Variant(java.lang.String value)
          Constructs a variant of type TYPE_WSTRING.
 
Method Summary
 boolean equals(java.lang.Object other)
          Compares the variant to another object.
 java.math.BigInteger getBigInteger()
          Returns the BigInteger representation of this Variant.
 char getChar()
          Returns the character representation of this Variant.
 int getInt()
          Returns the integer representation of this Variant.
 long getLong()
          Returns the long integer representation of this Variant.
 short getShort()
          Returns the short integer representation of this Variant.
 java.lang.String getString()
          Returns the string representation of this Variant.
 byte[] getStringAsUTF8()
          Returns the string representation of this Variant.
 int getType()
          Returns the type of this Variant.
 int hashCode()
          Returns a hash code value for the object.
 java.lang.String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UINT32_MAX_VALUE

public static final long UINT32_MAX_VALUE
The maximum value of a UINT32.

See Also:
Constant Field Values

UINT32_MIN_VALUE

public static final long UINT32_MIN_VALUE
The minimum value of a UINT32.

See Also:
Constant Field Values

UINT64_MAX_VALUE

public static final java.math.BigInteger UINT64_MAX_VALUE
The maximum value of a UINT64.


UINT64_MIN_VALUE

public static final java.math.BigInteger UINT64_MIN_VALUE
The minimum value of a UINT64.


TYPE_WSTRING

public static final int TYPE_WSTRING
Constant for specifying the string variant type. Must be paired with a String object on construction.

See Also:
Constant Field Values

TYPE_UINT16

public static final int TYPE_UINT16
Constant for specifying the unsigned 16-bit integer variant type Must be paired with a Character object on construction.

See Also:
Constant Field Values

TYPE_UINT32

public static final int TYPE_UINT32
Constant for specifying the unsigned 32-bit integer variant type Must be paired with a Long object when passed into the constructor. The value of the Long object must be between UINT32_MIN_VALUE and UINT32_MAX_VALUE.

See Also:
Constant Field Values

TYPE_UINT64

public static final int TYPE_UINT64
Constant for specifying the unsigned 64-bit integer variant type Must be paired with a BigInteger or Long object when passed into the constructor.

See Also:
Constant Field Values

TYPE_INT16

public static final int TYPE_INT16
Constant for specifying the signed 16-bit integer variant type Must be paired with a Short object when passed into the constructor.

See Also:
Constant Field Values

TYPE_INT32

public static final int TYPE_INT32
Constant for specifying the signed integer variant type Must be paired with an Integer object when passed into the constructor.

See Also:
Constant Field Values

TYPE_INT64

public static final int TYPE_INT64
Constant for specifying the signed long integer variant type Must be paired with a Long object when passed into the constructor.

See Also:
Constant Field Values

TYPE_NULL

public static final int TYPE_NULL
Constant for specifying the NULL variant type Must be paired with a null pointer when passed into the constructor.

See Also:
Constant Field Values
Constructor Detail

Variant

public Variant(int type,
               java.lang.Object value)
        throws IncorrectTypeException,
               NumericOverflowException
Constructs a variant of the given type and value.

Parameters:
type - Type of this Variant.
value - Value of this Variant.
Throws:
IncorrectTypeException - if the type doesn't match the object given.
NumericOverflowException - if the user tries to use a UINT32 with a value out of range.

Variant

public Variant(java.lang.String value)
Constructs a variant of type TYPE_WSTRING.

Parameters:
value - Value of this Variant.
Method Detail

getChar

public char getChar()
             throws NumericOverflowException,
                    IncorrectTypeException
Returns the character representation of this Variant.

Returns:
Character representation of this Variant.
Throws:
NumericOverflowException - if overflow or underflow occurs.
IncorrectTypeException - if the value could not be interpreted as a character.

getInt

public int getInt()
           throws NumericOverflowException,
                  IncorrectTypeException
Returns the integer representation of this Variant.

Returns:
Integer representation of this Variant.
Throws:
NumericOverflowException - if overflow or underflow occurs.
IncorrectTypeException - if the value could not be interpreted as a number.

getLong

public long getLong()
             throws IncorrectTypeException,
                    NumericOverflowException
Returns the long integer representation of this Variant.

Returns:
Long integer representation of this Variant
Throws:
IncorrectTypeException - if the value could not be interpreted as a number.
NumericOverflowException - if overflow or underflow occurs.

getBigInteger

public java.math.BigInteger getBigInteger()
                                   throws IncorrectTypeException
Returns the BigInteger representation of this Variant.

Returns:
BigInteger representation of this Variant
Throws:
IncorrectTypeException - if the value could not be interpreted as a number.

getShort

public short getShort()
               throws NumericOverflowException,
                      IncorrectTypeException
Returns the short integer representation of this Variant.

Returns:
Short integer representation of this Variant.
Throws:
NumericOverflowException - if overflow or underflow occurs.
IncorrectTypeException - if the value could not be interpreted as a number.

getString

public java.lang.String getString()
Returns the string representation of this Variant.

Returns:
String representation for this Variant.

getStringAsUTF8

public byte[] getStringAsUTF8()
                       throws IncorrectTypeException,
                              java.io.UnsupportedEncodingException
Returns the string representation of this Variant.

Returns:
String representation of this Variant.
Throws:
java.io.UnsupportedEncodingException - if UTF-8 is not a supported Java String encoding.
IncorrectTypeException - if the value cannot be interpreted as a string.

getType

public int getType()
Returns the type of this Variant.

Returns:
Type of this Variant

toString

public java.lang.String toString()
Return a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this object.

equals

public boolean equals(java.lang.Object other)
Compares the variant to another object.

Overrides:
equals in class java.lang.Object
Parameters:
other - The other variant to compare with this one.
Returns:
true if and only if other is a Variant with a value which compares equal to the held value; false otherwise.

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

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


Copyright © 2006-2014 Simba Technologies Incorporated. All Rights Reserved.