borland.jbcl Packages  borland.jbcl Class Hierarchy  borland.jbcl.util 

Variant component

java.lang.Object
   +----borland.jbcl.util.Variant
           +----borland.jbcl.dataset.RowVariant
           +----borland.jbcl.dataset.ColumnVariant

About the Variant component

Variables  Constructors  Properties  Methods  

Implements Cloneable

The Variant class is a type storage class whose value can be one of many data types. It can hold data of these types:

Variant contains constants used to identify all of these data types. It also contains the methods to get and set data values and to perform operations on Variant data, such as addition, subtraction, and comparing one value to another.

In JBCL, the dataset package uses the Variant data type frequently because it can handle all types of data.


Variant variables

Variables implemented in this class

Variant constructors

Variant properties

*Read-only properties **Write-only properties

Properties implemented in this class

Properties implemented in java.lang.Object

Variant methods

Methods implemented in this class

Methods implemented in java.lang.Object


Variant variables

ASSIGNED_NULL

  public static final int ASSIGNED_NULL = 1
An integer constant used to identify a data type for values that are explicitly set to null. This is in contrast to data that is never assigned. See UNASSIGNED_NULL.

AssignedNull_S

  public static final String AssignedNull_S = "ASSIGNED_NULL"
A constant that displays an assigned null value as the string "ASSIGNED_NULL". An assigned null is a value explicitly set to null in contrast to one that is simply not assigned.

BIGDECIMAL

  public static final int BIGDECIMAL = 10
An integer constant used to identify the BigDecimal data type. BigDecimal values have an unlimited precision integer value and an integer scale factor.

BINARY_STREAM

  public static final int BINARY_STREAM = 12
An integer constant used to identify data of a binary stream.

BOOLEAN

  public static final int BOOLEAN = 11
An integer constant used to identify data of type boolean.

BYTE

  public static final int BYTE = 2
An integer constant used to identify data of type byte.

BYTE_ARRAY

  public static final int BYTE_ARRAY = 18
An integer constant used to identify data in a byte array.

BigDecimalType_S

  public static final String BigDecimalType_S = "BIGDECIMAL"
A constant that represents the BigDecimal data type as the string "BIGDECIMAL".

BinaryStreamType_S

  public static final String BinaryStreamType_S = "BINARY_STREAM"
A constant that represents a binary stream as the string "BINARY_STREAM".

BooleanType_S

  public static final String BooleanType_S = "BOOLEAN"
A constant that represents the boolean data type as the string "BOOLEAN".

ByteArrayType_S

  public static final String ByteArrayType_S = "BYTE_ARRAY"
A constant that displays a byte array as the string "BYTE_ARRAY".

ByteType_S

  public static final String ByteType_S = "BYTE"
A constant that represents the byte data type as the string "BYTE".

DATE

  public static final int DATE = 13
An integer constant used to identify the Date data type.

DOUBLE

  public static final int DOUBLE = 7
An integer constant used to identify the double data type.

DateType_S

  public static final String DateType_S = "DATE"
A constant that represents the Date data type as the string "DATE".

DoubleType_S

  public static final String DoubleType_S = "DOUBLE"
A constant that represents the double date type as the string "DOUBLE".

FLOAT

  public static final int FLOAT = 6
An integer constant used to identify the float data type.

FloatType_S

  public static final String FloatType_S = "FLOAT"
A constant that represents the float data type as the string "FLOAT".

INT

  public static final int INT = 4
An integer constant used to identify the int data type.

IntType_S

  public static final String IntType_S = "INT"
A constant that represents the int data type as the string "INT".

LONG

  public static final int LONG = 5
An integer constant used to identify the long data type.

LongType_S

  public static final String LongType_S = "LONG"
A constant that represents the long data type as the string "LONG".

MaxTypes

  public static final int MaxTypes = 18
The maximum number of data types Variant can handle.

NULL_TYPES

  public static final int NULL_TYPES = 1
An integer constant used to identify null data. Null data can be either assigned or unassigned. See ASSIGNED_NULL and UNASSIGNED_NULL.

OBJECT

  public static final int OBJECT = 17
An integer constant used to identify the Object data type.

ObjectType_S

  public static final String ObjectType_S = "OBJECT"
A constant that represents the Object data type as the string "OBJECT".

SHORT

  public static final int SHORT = 3
An integer constant used to identify the short data type.

STRING

  public static final int STRING = 16
An integer constant used to identify the String data type.

ShortType_S

  public static final String ShortType_S = "SHORT"
A constant that represents the short data type as the string "SHORT".

StringType_S

  public static final String StringType_S = "STRING"
A constant that represents the String data type as the string "STRING".

TIME

  public static final int TIME = 14
An integer constant used to identify the Time data type.

TIMESTAMP

  public static final int TIMESTAMP = 15
An integer constant used to identify the TimeStamp data type.

TimeType_S

  public static final String TimeType_S = "TIME"
A constant that represents the Time data type as the string "TIME".

TimestampType_S

  public static final String TimestampType_S = "TIMESTAMP"
A constant that represents the TimeStamp data type as the string "TIMESTAMP".

UNASSIGNED_NULL

  public static final int UNASSIGNED_NULL = 0
An integer constant used to identify an unassigned null value. An unassigned null value is a data value that was never assigned. This is in contrast to an assigned null value that is explicitly assigned. See ASSIGNED_NULL.

UnassignedNull_S

  public static final String UnassignedNull_S = "UNASSIGNED_NULL"
A constant that represents an unassigned null as the string "UNASSIGNED_NULL".

UnknownType_S

  public static final String UnknownType_S = "UNKNOWN"
A constant that represents an unknown data type as the string "UNKNOWN".

nullVariant

  public static final Variant nullVariant = new Variant(UNASSIGNED_NULL)
An integer constant used to identify a Variant data type with an unassigned null data value.

Variant constructors

Variant()

  public Variant()
Constructs a Variant object without specifying the explicit data type.

Variant(int)

  public Variant(int dataType)
Constructs a Variant object that can contain data of the type specified with the dataType parameter. Variants instantiated with this constructor must have the results of all set operations be of the type specified.

Parameters:

dataType
If this constructor is used, all set operations must be of dataType that the Variant was constructed with.

Variant properties

arrayLength

 public final int getArrayLength()
 public final void setArrayLength(int length)
Retrieves and sets the length of an array.

Parameters:

length
The length of the array.

asBigDecimal

 public final BigDecimal getAsBigDecimal()
Obtains a data value as a BigDecimal data type. It can handle data identified as type BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, UNASSIGNED_NULL, and ASSIGNED_NULL.

asDouble

 public final double getAsDouble()
 public final void setAsDouble(double val)
Retrieves and sets the value of this Variant as a double data type. It can obtain data identified as type BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, UNASSIGNED_NULL, and ASSIGNED_NULL. It can set data of type FLOAT and DOUBLE.

Parameters:

val
The data value of type double.

asInt

 public final int getAsInt()
 public final void setAsInt(int val)
Retrieves and sets the value of this Variant as a int data type. It can obtain data identified as type BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, UNASSIGNED_NULL, and ASSIGNED_NULL. It can set data of type BYTE and SHORT.

Parameters:

val
The data value of type int.

asLong

 public final long getAsLong()
Retrieves and sets the value of this Variant as a long data type. It can obtain data identified as type BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, UNASSIGNED_NULL, and ASSIGNED_NULL.

Parameters:

val
The data value of type long.

assignedNull

 public final boolean isAssignedNull()
Determines whether the data value is an assigned null value. If it returns true, the value is an assigned null value; otherwise, it is not.

bigDecimal

 public final BigDecimal getBigDecimal()
 public final void setBigDecimal(java.math.BigDecimal val)
 public final void setBigDecimal(java.lang.String val)
Retrieves and sets the value of this Variant to a BigDecimal data value.

Parameters:

val
The BigDecimal data value. Specify val as either a BigDecimal or a String data type.

binaryStream

 public final InputStream getBinaryStream()
 public final void set(java.io.InputStream val)
Reads data from and stores data to a binary stream.

Binary streams are used to store images such as GIF and JPEG images. They must be re-readable as they are read each tiem they are painted. The InputStream.markSupported() method must return true and the InputStream.mark(0) method should be called before the BinaryStream is added to the DataSet

The GridControl and ImageControl components assume that DataSet columns of type Variant.BinaryStream are displayable images. Set the column's visible property to false to prevent their display.

If your custom BinaryStream requires a custom editor or painter, set these Column level properties to your custom edit and painter classes.

Parameters:

val
The input stream the data is read from and stored to.

boolean

 public final boolean getBoolean()
 public final void setBoolean(boolean val)
Retrieves and sets the value of this Variant to a boolean data value.

Parameters:

val
The boolean value to set the Variant to. Valid values are true or false.

byte

 public final byte getByte()
 public final void setByte(int val)
Retrieves and sets the value of this Variant to a byte data value.

Parameters:

val
The new value for this Variant.

byteArray

 public final byte[] getByteArray()
Retrieves the value of this Variant as a byte array.

date

 public final java.sql.Date getDate()
 public final void setDate(java.sql.Date val)
 public final void setDate(long val)
Retrieves and sets the value of this Variant to a Date data value.

Parameters:

val
The new date. val can be of the java.sql.Date type or a long value.

displayValue

 public final Object getDisplayValue()
Retrieves the value of the Variant.

double

 public final double getDouble()
 public final void setDouble(double val)
Retrieves and sets the value of this Variant to a double data value.

Parameters:

val
The new value.

float

 public final float getFloat()
 public final void setFloat(float val)
Retrieves and sets the value of this Variant to a float data value.

Parameters:

val
The new value.

int

 public final int getInt()
 public final void setInt(int val)
Retrieves and sets the value of this Variant to an int data value.

Parameters:

val
The new value.

long

 public final long getLong()
 public final void setLong(long val)
Retrieves and sets the value of this Variant to a long data value.

Parameters:

val
The new value.

null

 public final boolean isNull()
 public final void setNull(int nullType)
Determines whether a data value is null. If null is true, the data value is null; otherwise, the data value is not null.

object

 public final Object getObject()
 public final void setObject(java.lang.Object val)
Retrieves and sets the value of this Variant to an Object data value.

Parameters:

val
The new value.

setType

 public final int getSetType()
Returns the set type of the Variant as an integer. Possible values are the type constants of Variant. For example, if the data type is boolean, getSetType() returns 11, the value of the BOOLEAN constant. setType is a private variable used internally by the Variant class. It is used to enforce safe set operations.

short

 public final short getShort()
 public final void setShort(short val)
Retrieves and sets the value of this Variant to a short data value.

Parameters:

val
The new value.

string

 public final String getString()
 public final void setString(java.lang.String val)
Retrieves and sets the value of this Variant to a String data value.

Parameters:

val
The new value as a string.

time

 public final Time getTime()
 public final void setTime(java.sql.Time val)
 public final void setTime(long val)
Retrieves and sets the value of this Variant to a Time data value.

Parameters:

val
The new value.

timestamp

 public final Timestamp getTimestamp()
 public final void setTimestamp(java.sql.Timestamp val)
 public final void setTimestamp(long val)
Retrieves and sets the value of this Variant to a Timestamp data value.

Parameters:

val
The new value.

type

 public final int getType()
Returns the data type. The integer returned is the value of one of the type constants of Variant. For example, a data type of double returns a value of 7, which is the value of the DOUBLE constant.

unassignedNull

 public final boolean isUnassignedNull()
Determines whether the data value is an unassigned null. An unassigned null is a value that was never assigned. If unassignedNull is true, the data was not assigned and is null. If it returns false, the data value might not be null or it might be an assigned null value.

variant

 public final void setVariant(borland.jbcl.util.Variant value)
Sets the value of this Variant to a Variant data value.

Parameters:

val
The new value.

Variant methods

add(borland.jbcl.util.Variant, borland.jbcl.util.Variant)

  public void add(borland.jbcl.util.Variant value2, borland.jbcl.util.Variant result)
Adds a value to this Variant, storing the result in the result parameter.
value2
The value added to this Variant.
result
The result of the two Variant values added together.

clone()

  public Object clone()
Creates a copy of this Variant, returning the copied object.

Overrides: java.lang.Object.clone()

compareTo(borland.jbcl.util.Variant)

  public int compareTo(borland.jbcl.util.Variant value2)
Compares a Variant value to the value of this Variant, returning the result. If the result is zero, the two Variants are equal. If the returned value is less than zero (a negative integer), the value of this Variant is less than value2. If the returned value is greater than zero (a positive integer), the value of this Variant is greater than value2.

Parameters:

value2
The value this Variant is being compared to.

equals(borland.jbcl.util.Variant)

  public final boolean equals(borland.jbcl.util.Variant value)
Determines whether a Variant value is equal to this Variant value. If equals() returns true, the two Variant values are of the same type and are equal in value. A returned value of false indicates that the two values differ in value or type.

Parameters:

value
The Variant value being compared to the data type and value of this Variant.

setAsDouble(int, double)

  public final void setAsDouble(int type, double val)
Sets the value of this Variant of a specified type as a double data type.

Parameters:

type
The type of the new data value. Use one of the type constants to specify the data type.
val
The new value.

setAsInt(int, int)

  public final void setAsInt(int type, int val)
Sets the value of this Variant of a specified type as an int data type.

Parameters:

type
The type of the new data value. Use one of the type constants to specify the data type.
val
The new value.

setAssignedNull()

  public final void setAssignedNull()
Sets the value of the Variant as an assigned null. An assigned null is a value that has been explicitly set to null in contrast to one that is simply unassigned.

setByteArray(byte[], int)

  public final void setByteArray(byte[] val, int length)
Sets the value of the Variant to a new array of bytes.

Parameters:

val
The new array of bytes that becomes the new value of this Variant.
length
The length of the new byte array.

setTimestamp(long, int)

  public final void setTimestamp(long val, int nanos)
Sets the value of the Variant to a Timestamp value.

Parameters:

val
The new value as a long value.
nanos
The number of nanoseconds in the Timestamp value.

setUnassignedNull()

  public final void setUnassignedNull()
Sets the value of this Variant to an unassigned null. An assigned null is a null value that has not been explicitly assigned as null.

subtract(borland.jbcl.util.Variant, borland.jbcl.util.Variant)

  public void subtract(borland.jbcl.util.Variant value2, borland.jbcl.util.Variant result)
Subtracts a Variant value from the value of this Variant, storing the result in the result parameter.

Parameters:

value2
The value being subtracted from this Variant.
result
The difference between the two Variant values.

toString()

  public final String toString()
Converts the Variant value to a string.

Overrides: java.lang.Object.toString()

typeId(java.lang.String)

  public static int typeId(java.lang.String name)
Returns the integer value that represents the specified type name. For example, a name value of "" returns an integer of 11.

Parameters:

name
The name of a data type. Specify the name using one of the data type constants of Variant. For example, BOOLEAN is the name of the BOOLEAN constant for a boolean data type.

typeName(int)

  public static String typeName(int type)
Returns the name of a data type as a string. For example, the string representation of a BOOLEAN data type is "BOOLEAN".

Parameters:

type
The data type. Specify the type using one of the data type constants of Variant. For example, BOOLEAN is the name of the constant for a boolean data type.

typeOf(java.lang.String)

  public static int typeOf(java.lang.String typeName)
Returns an integer that identifies the data type specified in the typeName parameter.

Parameters:

typeName
The name of a data type as a string. For example, the string "BOOLEAN" results in an integer value of 11, which is the value of the BOOLEAN constant.