Diamond Control Suite 3.0

diamondedge.util
Class Variant

java.lang.Object
  extended by diamondedge.util.Variant
All Implemented Interfaces:
Serializable, Cloneable

public class Variant
extends Object
implements Cloneable, Serializable

See Also:
Serialized Form

Field Summary
static short ARRAY
          Flag that is OR'd in with the other vartypes to indicate an array of that type.
static short BOOLEAN
          Boolean data type (true/false).
static short BYTE
          Byte (signed 1 byte).
static short DATE
          Date data type.
static short DECIMAL
          BigDecimal (scaled floating-point) data type.
static short DOUBLE
          Double-precision floating-point data type.
static short EMPTY
          Empty (uninitialized) data type.
static short ERROR
          Integer data type (4 byte) holding an error code.
static short FLOAT
          Single-precision floating-point data type.
static short INTEGER
          Integer data type (4 byte).
static short LONG
          Long data type (8 byte).
static short NULL
          Null (no valid data) data type.
static short OBJECT
          Object data type (any object other than Date, String, BigDecimal).
static short SHORT
          Short data type (2 byte).
static short STRING
          String data type.
static short VARIANT
          Not used as a vartype for Variants but indicates that a Variant is needed or used.
 
Constructor Summary
Variant()
           
Variant(boolean val)
           
Variant(Date val)
           
Variant(double val)
           
Variant(int val)
           
Variant(int val, int vt)
           
Variant(Object val)
           
Variant(Object val, int vt)
           
Variant(String val)
           
 
Method Summary
 Variant add(Variant val)
          Returns a Variant whose value is (this + val).
 void changeType(int vt)
           
 Object clone()
           
 int compareTo(Object v)
          Compares the Variant to another object numerically or lexicographically depending on the datatypes.
 int compareTo(Variant v)
          Compares two Variants numerically or lexicographically depending on the datatypes.
 Variant divide(Variant val)
          Returns a Variant whose value is (this / val).
 boolean equals(double testVal)
           
 boolean equals(int testVal)
           
 boolean equals(Object obj)
           
 String getTypeName()
           
static Variant getValue(Object obj, String propName)
          Perform a late-bound retrieving of a property value on the given object
 Variant getValue(String propName)
          Perform a late-bound retrieving of a property value on the object stored in this variant Note: this operation is slow due to dynamically looking up meta information at runtime.
 Variant getValue(String propName, int[] dims)
          Perform a late-bound retrieving of a property value on the object stored in this variant The property on the object in this variant should be an array.
 Variant getValueAt(int index)
          Perform a late-bound retrieving of an element of the array stored in this variant This variant should be holding a single dimensioned array.
 Variant getValueAt(int[] indicies)
          Perform a late-bound retrieving of an element of the array stored in this variant The argument specifies the array indicies.
 int getVarType()
           
static int getVarType(Class cls)
           
static int getVarType(Object val)
           
 int hashCode()
           
static Variant invoke(Object obj, String methName, Variant[] args)
           
 Variant invoke(String methName, Variant[] args)
          Perform a late-bound function call on the object stored in this variant Note: this operation is slow due to dynamically looking up meta information at runtime.
 boolean isArray()
           
 boolean isDate()
           
 boolean isEmpty()
           
 boolean isError()
           
 boolean isNull()
           
 boolean isNumeric()
           
static boolean isNumeric(Class cls)
           
 boolean isObject()
           
 Variant multiply(Variant val)
          Returns a Variant whose value is (this * val).
 Variant negate()
          Returns a Variant whose value is (-this).
 void set(BigDecimal val)
           
 void set(boolean val)
           
 void set(byte val)
           
 void set(Date val)
           
 void set(double val)
           
 void set(float val)
           
 void set(int val)
           
 void set(int val, int vt)
           
 void set(long val)
           
 void set(Object val)
           
 void set(Object val, int vt)
           
 void set(short val)
           
 void set(String val)
           
 Variant setNull()
           
static void setValue(Object obj, String propName, Variant newval)
          Perform a late-bound setting of a property value on the given object
 void setValue(String propName, Variant newval)
          Perform a late-bound setting of a property value on the object stored in this variant Note: this operation is slow due to dynamically looking up meta information at runtime.
 void setValueAt(int[] indicies, Variant newval)
          Perform a late-bound setting of an element of the array stored in this variant The argument specifies the array indicies.
 void setValueAt(int index, Variant newval)
          Perform a late-bound setting of an element of the array stored in this variant This variant should be holding a single dimensioned array.
 Variant subtract(Variant val)
          Returns a Variant whose value is (this - val).
 boolean toBoolean()
           
 byte toByte()
           
 byte[] toBytes()
           
 Date toDate()
           
 Date toDateNew()
           
 BigDecimal toDecimal()
           
 double toDouble()
           
 float toFloat()
           
 int toInt()
           
 long toLong()
           
 Object toObject()
           
 short toShort()
           
 String toString()
           
static String typeName(int vartype)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final short EMPTY
Empty (uninitialized) data type.

See Also:
Constant Field Values

NULL

public static final short NULL
Null (no valid data) data type. Typically used to explicitly indicate that the data is null such as in a value from a database.

See Also:
Constant Field Values

BYTE

public static final short BYTE
Byte (signed 1 byte).

See Also:
Constant Field Values

SHORT

public static final short SHORT
Short data type (2 byte).

See Also:
Constant Field Values

INTEGER

public static final short INTEGER
Integer data type (4 byte).

See Also:
Constant Field Values

ERROR

public static final short ERROR
Integer data type (4 byte) holding an error code.

See Also:
Constant Field Values

LONG

public static final short LONG
Long data type (8 byte).

See Also:
Constant Field Values

FLOAT

public static final short FLOAT
Single-precision floating-point data type.

See Also:
Constant Field Values

DOUBLE

public static final short DOUBLE
Double-precision floating-point data type.

See Also:
Constant Field Values

DECIMAL

public static final short DECIMAL
BigDecimal (scaled floating-point) data type.

See Also:
Constant Field Values

BOOLEAN

public static final short BOOLEAN
Boolean data type (true/false).

See Also:
Constant Field Values

VARIANT

public static final short VARIANT
Not used as a vartype for Variants but indicates that a Variant is needed or used.

See Also:
Constant Field Values

OBJECT

public static final short OBJECT
Object data type (any object other than Date, String, BigDecimal).

See Also:
Constant Field Values

DATE

public static final short DATE
Date data type.

See Also:
Constant Field Values

STRING

public static final short STRING
String data type.

See Also:
Constant Field Values

ARRAY

public static final short ARRAY
Flag that is OR'd in with the other vartypes to indicate an array of that type.

See Also:
Constant Field Values
Constructor Detail

Variant

public Variant()

Variant

public Variant(int val)

Variant

public Variant(double val)

Variant

public Variant(Object val)

Variant

public Variant(Object val,
               int vt)

Variant

public Variant(boolean val)

Variant

public Variant(String val)

Variant

public Variant(Date val)

Variant

public Variant(int val,
               int vt)
Method Detail

compareTo

public int compareTo(Variant v)
Compares two Variants numerically or lexicographically depending on the datatypes.
  return 0 if value contained in variants are equal
  return a value > 0 if this variants value is > than variant v's value
  return a value < 0 if this variant's value is < than variant v's value


compareTo

public int compareTo(Object v)
Compares the Variant to another object numerically or lexicographically depending on the datatypes.
  return 0 if value contained in variants are equal
  return a value > 0 if this variants value is > than variant v's value
  return a value < 0 if this variant's value is < than variant v's value


equals

public boolean equals(Object obj)
Overrides:
equals in class Object

equals

public boolean equals(int testVal)

equals

public boolean equals(double testVal)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getVarType

public final int getVarType()

getVarType

public static int getVarType(Class cls)

getVarType

public static int getVarType(Object val)

typeName

public static String typeName(int vartype)

getTypeName

public final String getTypeName()

changeType

public void changeType(int vt)
                throws Exception
Throws:
Exception

set

public final void set(Object val)

set

public final void set(Object val,
                      int vt)

set

public final void set(Date val)

set

public final void set(boolean val)

set

public final void set(byte val)

set

public final void set(short val)

set

public final void set(int val)

set

public final void set(int val,
                      int vt)

set

public final void set(long val)

set

public final void set(BigDecimal val)

set

public final void set(float val)

set

public final void set(double val)

set

public final void set(String val)

setNull

public final Variant setNull()

toBoolean

public final boolean toBoolean()

toInt

public final int toInt()

toLong

public final long toLong()

toDouble

public final double toDouble()

toDecimal

public final BigDecimal toDecimal()

toString

public final String toString()
Overrides:
toString in class Object

toBytes

public final byte[] toBytes()

toByte

public final byte toByte()

toShort

public final short toShort()

toFloat

public final float toFloat()

toDate

public final Date toDate()

toDateNew

public final Date toDateNew()

toObject

public final Object toObject()

isArray

public final boolean isArray()

isDate

public final boolean isDate()

isEmpty

public final boolean isEmpty()

isError

public final boolean isError()

isNull

public final boolean isNull()

isNumeric

public static boolean isNumeric(Class cls)

isNumeric

public final boolean isNumeric()

isObject

public final boolean isObject()

clone

public Object clone()
Overrides:
clone in class Object

invoke

public final Variant invoke(String methName,
                            Variant[] args)
                     throws IllegalAccessException,
                            InvocationTargetException
Perform a late-bound function call on the object stored in this variant Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the object stored in the variant and casting it to the appropriate type and then calling the given function, directly.

Throws:
IllegalAccessException
InvocationTargetException

invoke

public static Variant invoke(Object obj,
                             String methName,
                             Variant[] args)
                      throws IllegalAccessException,
                             InvocationTargetException
Throws:
IllegalAccessException
InvocationTargetException

setValue

public final void setValue(String propName,
                           Variant newval)
                    throws IllegalAccessException,
                           NoSuchFieldException
Perform a late-bound setting of a property value on the object stored in this variant Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the object stored in the variant and casting it to the appropriate type and then set the value of the given property, , directly.

Throws:
IllegalAccessException
NoSuchFieldException

setValue

public static void setValue(Object obj,
                            String propName,
                            Variant newval)
                     throws IllegalAccessException,
                            NoSuchFieldException
Perform a late-bound setting of a property value on the given object

Throws:
IllegalAccessException
NoSuchFieldException

getValue

public final Variant getValue(String propName)
                       throws IllegalAccessException,
                              NoSuchFieldException
Perform a late-bound retrieving of a property value on the object stored in this variant Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the object stored in the variant and casting it to the appropriate type and then get the value of the given property, , directly.

Throws:
IllegalAccessException
NoSuchFieldException

getValue

public static Variant getValue(Object obj,
                               String propName)
                        throws IllegalAccessException,
                               NoSuchFieldException
Perform a late-bound retrieving of a property value on the given object

Throws:
IllegalAccessException
NoSuchFieldException

getValue

public final Variant getValue(String propName,
                              int[] dims)
                       throws IllegalAccessException,
                              NoSuchFieldException
Perform a late-bound retrieving of a property value on the object stored in this variant The property on the object in this variant should be an array. The argument specifies the array indicies. Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the object stored in the variant and casting it to the appropriate type and then get the value of the given property, , directly.

Throws:
IllegalAccessException
NoSuchFieldException

getValueAt

public final Variant getValueAt(int index)
Perform a late-bound retrieving of an element of the array stored in this variant This variant should be holding a single dimensioned array. The argument specifies the array index. Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the array stored in the variant and casting it to the appropriate array type and then get the element using the standard array notation using []'s.


getValueAt

public final Variant getValueAt(int[] indicies)
Perform a late-bound retrieving of an element of the array stored in this variant The argument specifies the array indicies. Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the array stored in the variant and casting it to the appropriate array type and then get the element using the standard array notation using []'s.


setValueAt

public final void setValueAt(int index,
                             Variant newval)
Perform a late-bound setting of an element of the array stored in this variant This variant should be holding a single dimensioned array. The argument specifies the array index. Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the array stored in the variant and casting it to the appropriate array type and then set the element using the standard array notation using []'s.


setValueAt

public final void setValueAt(int[] indicies,
                             Variant newval)
Perform a late-bound setting of an element of the array stored in this variant The argument specifies the array indicies. Note: this operation is slow due to dynamically looking up meta information at runtime. You should replace this call with getting the array stored in the variant and casting it to the appropriate array type and then set the element using the standard array notation using []'s.


add

public final Variant add(Variant val)
Returns a Variant whose value is (this + val).

Parameters:
val - value to be added to this Variant.
Returns:
this + val

subtract

public final Variant subtract(Variant val)
Returns a Variant whose value is (this - val).

Parameters:
val - value to be subtracted from this Variant.
Returns:
this - val

multiply

public final Variant multiply(Variant val)
Returns a Variant whose value is (this * val).

Parameters:
val - value to be multiplied by this Variant.
Returns:
this * val

divide

public final Variant divide(Variant val)
Returns a Variant whose value is (this / val).

Parameters:
val - value by which this Variant is to be divided.
Returns:
this / val
Throws:
ArithmeticException - val==0

negate

public final Variant negate()
Returns a Variant whose value is (-this).

Returns:
-this

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.