borland Packages  Class Hierarchy  dx.dataset Package 

Variant component

java.lang.Object
   +----com.borland.dx.dataset.Variant
           +----com.borland.dx.dataset.ColumnVariant
           +----com.borland.dx.dataset.RowVariant

About the Variant component

Variables  Constructors  Properties  Methods  

Implements Serializable, Cloneable

The Variant class is a type of 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. 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
Constant that identifies a data type for values that are explicitly set to null. This is in contrast to data that is never assigned.

See also: 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.

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"
This constant was deprecated. Use InputStreamType_S instead.

BOOLEAN

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

BooleanType_S

  public static final String BooleanType_S = "BOOLEAN"
A constant that represents the boolean data type as the string "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.

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.

DateType_S

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

DOUBLE

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

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".

INPUTSTREAM

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

InputStreamType_S

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

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.

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.

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.

ShortType_S

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

STRING

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

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.

TimestampType_S

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

TimeType_S

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

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".

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 get or set operations be of the type specified.

Parameters:

dataType
If this constructor is used, all set operations must be of the data type from which the Variant was constructed.

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, TIME, DATE, TIMESTAMP, UNASSIGNED_NULL, and ASSIGNED_NULL.

asBoolean

 public final boolean getAsBoolean()
Read-only property that obtains a data value as a boolean data type. It can handle data identified as type BOOLEAN, STRING, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, TIME, DATE, and TIMESTAMP.

asDate

 public final void setAsDate(Variant value)
Write-only property that sets the value of this Variant as a date or date and time value. It can set data identified as type DATE, BOOLEAN, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, TIME, and TIMESTAMP.

asDouble

 public final double getAsDouble()
Read-only property that retrieves the value of this Variant as a double data type. It can obtain data identified as type BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, TIME, DATE, TIMESTAMP, UNASSIGNED_NULL, and ASSIGNED_NULL.

asFloat

 public final float getAsFloat()
Read-only property that retrieves the value of this Variant as a float data type. It can obtain data identified as type BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, TIME, DATE, TIMESTAMP, UNASSIGNED_NULL, and ASSIGNED_NULL.

asInt

 public final int getAsInt()
Read-only property that retrieves the value of this Variant as a int data type. It can obtain data identified as type BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, TIME, DATE, TIMESTAMP, UNASSIGNED_NULL, and ASSIGNED_NULL.

asLong

 public final long getAsLong()
Read-only property that retrieves the value of this Variant as a long data type. It can obtain data identified as type BOOLEAN, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, TIMESTAMP, TIME, DATE, UNASSIGNED_NULL, and ASSIGNED_NULL.

asObject

 public Object getAsObject()
Read-only property that retrieves the value of this Variant as an object data type.

asShort

 public final short getAsShort()
Read-only property that retrieves the value of this Variant as a short data type. It can obtain data identified as type BYTE, SHORT, INT, BOOLEAN, LONG, FLOAT, DOUBLE, BIGDECIMAL, TIMESTAMP, TIME, DATE, UNASSIGNED_NULL, and ASSIGNED_NULL.

assignedNull

 public final boolean isAssignedNull()
Read-only property that 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.

asTime

 public final void setAsTime(Variant value)
Sets Time to value.

Parameters:

value
If value is of type TIME, the value is copied directly. If value is of type BOOLEAN, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, DATE, TIMESTAMP, setAsTime is called with the return value from value.getAsLong(). If value is of type ASSIGNED_NULL or UNASSIGNED_NULL, Time is set to the same *_NULL value.

asTimestamp

 public final void setAsTimestamp(Variant value)
Sets Timestamp to value.

Parameters:

value
If value is of type TIME, the value is copied directly. If value is of type BOOLEAN, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, BIGDECIMAL, DATE, TIMESTAMP, setTimeStamp() is called with the return value from value.getAsLong(). If value is of type ASSIGNED_NULL or UNASSIGNED_NULL, Time is set to the same *_NULL value.

asVariant

 public final void setAsVariant(Variant value)
Write-only property that sets this Variant to the specified value. If value is not of the same data type as specified in the setType property, then an attempt is made to convert it to the data type of this Variant. An attempt to convert data from or to and int to or from a String generates a DataSetException. If you need such conversions, or prefer to perform data conversion yourself, wire the CoerceToColumn or CoerceFromColumn events as appropriate.

bigDecimal

 public final BigDecimal getBigDecimal()
 public final void setBigDecimal(BigDecimal val)
Stores the value of this Variant as a BigDecimal data value.

binaryStream

 public final InputStream getBinaryStream()
 public final void setBinaryStream(InputStream val)
This property was deprecated. Use the inputStream property.

boolean

 public final boolean getBoolean()
 public final void setBoolean(boolean val)
Stores the value of this Variant to a boolean data value. Valid values are true or false.

byte

 public final byte getByte()
 public final void setByte(byte val)
Stores the value of this Variant to a byte data value.

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)
Stores the value of this Variant as a Date data value. The val parameter 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)
Stores the value of this Variant to a double data value.

float

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

inputStream

 public final InputStream getInputStream()
 public final void setInputStream(InputStream val)

Input streams are used to read in images such as GIF and JPEG images. They must be re-readable as they are read each time 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.

If your custom InputStream 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.

int

 public final int getInt()
 public final void setInt(int val)
Stores 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)
Stores 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 ASSIGNED_NULL or UNASSIGNED_NULL; otherwise, the data value is not ASSIGNED_NULL or UNASSIGNED_NULL.

object

 public final Object getObject()
 public final void setObject(Object val)
Stores 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)
Stores the value of this Variant to a short data value.

Parameters:

val
The new value.

string

 public final String getString()
 public final void setString(String val)
Stores the value of this Variant as a String data value.

Parameters:

val
The new value as a string.

time

 public final Time getTime()
 public final void setTime(Time val)
 public final void setTime(long val)
Stores the value of this Variant as a Time data value.

Parameters:

val
The new value.

timestamp

 public final Timestamp getTimestamp()
 public final void setTimestamp(Timestamp val)
 public final void setTimestamp(long val)
Stores the value of this Variant as 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(Variant value)
Sets the value of this Variant as a Variant data value.

Parameters:

value
The new value.

Variant methods

add(com.borland.dx.dataset.Variant, com.borland.dx.dataset.Variant)

  public void add(Variant value2, Variant result)
Adds a value to this Variant, storing the result in the result parameter.

Parameters:

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(com.borland.dx.dataset.Variant)

  public int compareTo(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.

currentUTCTimeMillis()

  public static long currentUTCTimeMillis()
Returns System.currentTimeMillis() minus the active time zone offset to provide the current UTC time.

equals(com.borland.dx.dataset.Variant)

  public final boolean equals(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.

equalsInstance(com.borland.dx.dataset.Variant)

  public boolean equalsInstance(Variant value2)
Returns true if the value or value instance changed. Returns false for Variants storing different object reference values that may be equal. Provides a high speed test that indicates if two variants are equal. If true is returned, they are equal. If false is returned, they might still be equal.

getTimeZoneOffset()

  public static long getTimeZoneOffset()
Returns the time zone offset, in milliseconds, of the current time zone. Used internally by JDataStore.

setAsObject(java.lang.Object, int)

  public void setAsObject(Object object, int variantType)

Parameters:

object
The value to set.
variantType
Variant data type that the object maps to. For example, if the object is of type Integer, then variantType should be Variant.INT.

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.

setFromString(int, java.lang.String)

  public final void setFromString(int wantedType, String s)
Attempts to parse the passed string s to the type indicated by wantedType. Date values must be of the format "yyyy-mm-dd". Time values must be of the format "hh:mm:ss". Timestamp values must be of the format "yyyy-mm-dd hh:mm:ss.fffffffff", where f indicates a digit of the fractions of seconds. Boolean values are true for true, anything else is false.

setTimestamp(long, int)

  public final void setTimestamp(long val, int nanos)
Sets the value of the Variant as 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(com.borland.dx.dataset.Variant, com.borland.dx.dataset.Variant)

  public void subtract(Variant value2, 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(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(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.