borland Packages Class Hierarchy dx.dataset Package
java.lang.Object +----com.borland.dx.dataset.Variant +----com.borland.dx.dataset.ColumnVariant +----com.borland.dx.dataset.RowVariant
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.
public static final int ASSIGNED_NULL = 1Constant that identifies a data type for values that are explicitly set to null. This is in contrast to data that is never assigned.
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.
public static final int BIGDECIMAL = 10An integer constant used to identify the
BigDecimal
data type. BigDecimal
values have an unlimited precision integer value and an integer scale factor.
public static final String BigDecimalType_S = "BIGDECIMAL"A constant that represents the
BigDecimal
data type as the string "BIGDECIMAL".
public static final String BinaryStreamType_S = "BINARY_STREAM"This constant was deprecated. Use InputStreamType_S instead.
public static final int BOOLEAN = 11An integer constant used to identify data of type boolean.
public static final String BooleanType_S = "BOOLEAN"A constant that represents the boolean data type as the string "BOOLEAN".
public static final int BYTE = 2An integer constant used to identify data of type byte.
public static final int BYTE_ARRAY = 18An integer constant used to identify data in a byte array.
public static final String ByteArrayType_S = "BYTE_ARRAY"A constant that displays a byte array as the string "BYTE_ARRAY".
public static final String ByteType_S = "BYTE"A constant that represents the byte data type as the string "BYTE".
public static final int DATE = 13An integer constant used to identify the
Date
data type.
public static final String DateType_S = "DATE"A constant that represents the Date data type as the string "DATE".
public static final int DOUBLE = 7An integer constant used to identify the double data type.
public static final String DoubleType_S = "DOUBLE"A constant that represents the double date type as the string "DOUBLE".
public static final int FLOAT = 6An integer constant used to identify the float data type.
public static final String FloatType_S = "FLOAT"A constant that represents the float data type as the string "FLOAT".
public static final int INPUTSTREAM = 12An integer constant used to identify data of a input stream.
public static final String InputStreamType_S = "INPUTSTREAM"A constant that represents the INPUTSTREAM data type as the string "INPUTSTREAM".
public static final int INT = 4An integer constant used to identify the int data type.
public static final String IntType_S = "INT"A constant that represents the int data type as the string "INT".
public static final int LONG = 5An integer constant used to identify the long data type.
public static final String LongType_S = "LONG"A constant that represents the long data type as the string "LONG".
public static final int MaxTypes = 18The maximum number of data types
Variant
can handle.
public static final int NULL_TYPES = 1An integer constant used to identify null data. Null data can be either assigned or unassigned. See ASSIGNED_NULL and UNASSIGNED_NULL.
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.
public static final int OBJECT = 17An integer constant used to identify the
Object
data type.
public static final String ObjectType_S = "OBJECT"A constant that represents the
Object
data type as the string "OBJECT".
public static final int SHORT = 3An integer constant used to identify the short data type.
public static final String ShortType_S = "SHORT"A constant that represents the short data type as the string "SHORT".
public static final int STRING = 16An integer constant used to identify the
String
data type.
public static final String StringType_S = "STRING"A constant that represents the
String
data type as the string "STRING".
public static final int TIME = 14An integer constant used to identify the
Time
data type.
public static final int TIMESTAMP = 15An integer constant used to identify the
TimeStamp
data type.
public static final String TimestampType_S = "TIMESTAMP"A constant that represents the
TimeStamp
data type as the string "TIMESTAMP".
public static final String TimeType_S = "TIME"A constant that represents the
Time
data type as the string "TIME".
public static final int UNASSIGNED_NULL = 0An 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.
public static final String UnassignedNull_S = "UNASSIGNED_NULL"A constant that represents an unassigned null as the string "UNASSIGNED_NULL".
public static final String UnknownType_S = "UNKNOWN"A constant that represents an unknown data type as the string "UNKNOWN".
public Variant()Constructs a
Variant
object without specifying the explicit data type.
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.
dataType
public final int getArrayLength() public final void setArrayLength(int length)Retrieves and sets the length of an array.
length
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.
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.
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.
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.
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.
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.
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.
public Object getAsObject()Read-only property that retrieves the value of this
Variant
as an object data type.
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.
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.
public final void setAsTime(Variant value)Sets Time to value.
value
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.
public final void setAsTimestamp(Variant value)Sets Timestamp to value.
value
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.
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.
public final BigDecimal getBigDecimal() public final void setBigDecimal(BigDecimal val)Stores the value of this
Variant
as a BigDecimal
data value.
public final InputStream getBinaryStream() public final void setBinaryStream(InputStream val)This property was deprecated. Use the
inputStream
property.
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.
public final byte getByte() public final void setByte(byte val)Stores the value of this
Variant
to a byte data value.
public final byte[] getByteArray()Retrieves the value of this
Variant
as a byte array.
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.
public final Object getDisplayValue()Retrieves the value of the
Variant
.
public final double getDouble() public final void setDouble(double val)Stores the value of this
Variant
to a double data value.
public final float getFloat() public final void setFloat(float val)Stores the value of this
Variant
to a float data value.
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.
val
public final int getInt() public final void setInt(int val)Stores the value of this
Variant
to an int data value.
val
public final long getLong() public final void setLong(long val)Stores the value of this
Variant
to a long data value.
val
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.
public final Object getObject() public final void setObject(Object val)Stores the value of this
Variant
to an Object
data value.
val
public final boolean isSetAsObject()Currently used by dbSwing components to set a variant from an object. The
object
parameter is the value to set. The variantType
parameter is a Variant
data type that object
maps to. For example, if object
is of type Integer
, then variantType
should be Variant.INT
.
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.
public final short getShort() public final void setShort(short val)Stores the value of this
Variant
to a short data value.
val
public final int getStoreType()Returns whether the
Variant
is storing a byte array or an InputStream
.
public final String getString() public final void setString(String val)Stores the value of this
Variant
as a String
data value.
val
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.
val
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.
val
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.
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.
public final void setVariant(Variant value)Sets the value of this
Variant
as a Variant
data value.
value
public void add(Variant value2, Variant result)Adds a value to this
Variant
, storing the result in the result
parameter.
value2
Variant
.
result
Variant
values added together.
public Object clone()Creates a copy of this
Variant
, returning the copied object.
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
.
value2
Variant
is being compared to.
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.
value
Variant
value being compared to the data type and value of this Variant
.
public boolean equalsInstance(Variant value2)Returns true if the value or value instance changed. Returns false for
Variant
s 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.
public static long getTimeZoneOffset()Returns the time zone offset, in milliseconds, of the current time zone. Used internally.
public void setAsObject(Object object, int variantType)Currently used by dbSwing components to set a
Variant
from an Object
.
object
variantType
variantType
should be Variant.INT.
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.
public final void setByteArray(byte[] val, int length)Sets the value of the
Variant
to a new array of bytes.
val
Variant
.
length
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.
public final void setObject(byte[] buf, int length)The
buf
parameter is a serialized java object. The length
parameter indicates how much of buf
is used to store the serialized object.
public final void setTimestamp(long val, int nanos)Sets the value of the
Variant
as a Timestamp
value.
val
nanos
Timestamp
value.
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.
public void subtract(Variant value2, Variant result)Subtracts a
Variant
value from the value of this Variant
, storing the result in the result
parameter.
value2
Variant
.
result
Variant
values.
public final String toString()Converts the
Variant
value to a 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.
name
Variant
. For example, BOOLEAN is the name of the BOOLEAN constant for a boolean data type.
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".
type
Variant
. For example, BOOLEAN is the name of the constant for a boolean data type.
public static int typeOf(String typeName)Returns an integer that identifies the data type specified in the
typeName
parameter.
typeName