VariantType

Overview

This class is designed to read and write a Delphi-compatible variant type. The variant type can be used to represent a piece of data of unknown type and can hold different/changing types of data at runtime. A number of properties are defined in this class to access the data as regular Java types. The class tries to convert the data in all possible ways but if the data conversion is impossible in the particular case (e.g. a GUID can not be converted to a number) an exception with name VariantTypeException will be thrown. The similar exception is thrown in response to attempt to treat the data as an array while a single value is stored.

Location

 

constructor

Creates EmptyVariant.

 

constructor

 

VariantType()

constructor (VariantTypeCode, Object)

Creates VariantType with given type and value.

 

constructor(aDataType: VariantTypeCode; aValue: Object)

 

VariantType(VariantTypeCode aDataType, Object aValue)

Parameters:


constructor (Object)

Creates VariantType with given object.

 

constructor(aValue: Object)

 

VariantType(Object aValue)

Parameters:

  • aValue: Given object.

ArrayDataType

Data type of array.

 

property ArrayDataType: VariantTypeCode read;

 

VariantTypeCode ArrayDataType { __get; }

ArraySize

Size of array

 

property ArraySize: Integer read;

 

Integer ArraySize { __get; }

AsBoolean

Value as boolean

 

property AsBoolean: Boolean read write;

 

Boolean AsBoolean { __get; __set; }

AsData

Value as binary data.

 

property AsData: array of SByte read write;

 

SByte[] AsData { __get; __set; }

AsDate

Value as date.

 

property AsDate: Date read write;

 

Date AsDate { __get; __set; }

AsDecimal

Value as BigDecimal.

 

property AsDecimal: BigDecimal read write;

 

BigDecimal AsDecimal { __get; __set; }

AsDouble

Value as double.

 

property AsDouble: Double read write;

 

Double AsDouble { __get; __set; }

AsInt32

Value as int.

 

property AsInt32: Integer read write;

 

Integer AsInt32 { __get; __set; }

AsInt64

Value as long.

 

property AsInt64: Int64 read write;

 

Int64 AsInt64 { __get; __set; }

AsString

Value as string.

 

property AsString: String read write;

 

String AsString { __get; __set; }

AsUtfString

Value as UTF8 string.

 

property AsUtfString: String read write;

 

String AsUtfString { __get; __set; }

AsUuid

Value as UUID.

 

property AsUuid: UUID read write;

 

UUID AsUuid { __get; __set; }

AsVariant

Value as Variant.

 

property AsVariant: VariantType read write;

 

VariantType AsVariant { __get; __set; }

DataType

Data type of the variant.

 

property DataType: VariantTypeCode read;

 

VariantTypeCode DataType { __get; }

emptyVariant

Creates empty Variant.

 

class method emptyVariant: VariantType

 

static VariantType emptyVariant()

getItemAtIndex

Returns object in a specific position.

 

method getItemAtIndex(anIndex: Integer): VariantType

 

VariantType getItemAtIndex(Integer anIndex)

Parameters:

  • anIndex: Given position.

getVariantCode

Returns integer representation of Variant code.

 

class method getVariantCode(value: VariantTypeCode): Integer

 

static Integer getVariantCode(VariantTypeCode value)

Parameters:


getVariantType

Returns Variant type from integer code .

 

class method getVariantType(value: Integer): VariantTypeCode

 

static VariantTypeCode getVariantType(Integer value)

Parameters:


IsEmpty

Check for empty Variant.

 

property IsEmpty: Boolean read;

 

Boolean IsEmpty { __get; }

IsNull

Check for null Variant.

 

property IsNull: Boolean read;

 

Boolean IsNull { __get; }

nullVariant

Creates a null Variant value.

 

class method nullVariant: VariantType

 

static VariantType nullVariant()

setArrayLength

Calls to create variant array type, or increase/decrease array size.

 

method setArrayLength(aLength: Integer; aDataType: VariantTypeCode)

 

void setArrayLength(Integer aLength, VariantTypeCode aDataType)

Parameters:


setEmpty

Sets variant as empty.

 

method setEmpty

 

void setEmpty()

setItem

Sets specific object to specific index in an Variant array.

 

method setItem(anItem: VariantType; anIndex: Integer)

 

void setItem(VariantType anItem, Integer anIndex)

Parameters:

  • anItem: Given value.
  • anIndex: Given position.

setNull

Sets variant as null.

 

method setNull

 

void setNull()

Value

Value of the Variant.

 

property Value: Object read;

 

Object Value { __get; }

variantWithBoolean

Creates new Variant as boolean.

 

class method variantWithBoolean(aValue: Boolean): VariantType

 

static VariantType variantWithBoolean(Boolean aValue)

Parameters:

  • aValue: Given boolean value.

variantWithString

Creates new Variant as string.

 

class method variantWithString(aValue: String): VariantType

 

static VariantType variantWithString(String aValue)

Parameters:

  • aValue: Given String value.

 

ArrayDataType

Data type of array.

 

property ArrayDataType: VariantTypeCode read;

 

VariantTypeCode ArrayDataType { __get; }

ArraySize

Size of array

 

property ArraySize: Integer read;

 

Integer ArraySize { __get; }

AsBoolean

Value as boolean

 

property AsBoolean: Boolean read write;

 

Boolean AsBoolean { __get; __set; }

AsData

Value as binary data.

 

property AsData: array of SByte read write;

 

SByte[] AsData { __get; __set; }

AsDate

Value as date.

 

property AsDate: Date read write;

 

Date AsDate { __get; __set; }

AsDecimal

Value as BigDecimal.

 

property AsDecimal: BigDecimal read write;

 

BigDecimal AsDecimal { __get; __set; }

AsDouble

Value as double.

 

property AsDouble: Double read write;

 

Double AsDouble { __get; __set; }

AsInt32

Value as int.

 

property AsInt32: Integer read write;

 

Integer AsInt32 { __get; __set; }

AsInt64

Value as long.

 

property AsInt64: Int64 read write;

 

Int64 AsInt64 { __get; __set; }

AsString

Value as string.

 

property AsString: String read write;

 

String AsString { __get; __set; }

AsUtfString

Value as UTF8 string.

 

property AsUtfString: String read write;

 

String AsUtfString { __get; __set; }

AsUuid

Value as UUID.

 

property AsUuid: UUID read write;

 

UUID AsUuid { __get; __set; }

AsVariant

Value as Variant.

 

property AsVariant: VariantType read write;

 

VariantType AsVariant { __get; __set; }

DataType

Data type of the variant.

 

property DataType: VariantTypeCode read;

 

VariantTypeCode DataType { __get; }

IsEmpty

Check for empty Variant.

 

property IsEmpty: Boolean read;

 

Boolean IsEmpty { __get; }

IsNull

Check for null Variant.

 

property IsNull: Boolean read;

 

Boolean IsNull { __get; }

Value

Value of the Variant.

 

property Value: Object read;

 

Object Value { __get; }

 

emptyVariant

Creates empty Variant.

 

class method emptyVariant: VariantType

 

static VariantType emptyVariant()

getVariantCode

Returns integer representation of Variant code.

 

class method getVariantCode(value: VariantTypeCode): Integer

 

static Integer getVariantCode(VariantTypeCode value)

Parameters:


getVariantType

Returns Variant type from integer code .

 

class method getVariantType(value: Integer): VariantTypeCode

 

static VariantTypeCode getVariantType(Integer value)

Parameters:


nullVariant

Creates a null Variant value.

 

class method nullVariant: VariantType

 

static VariantType nullVariant()

variantWithBoolean

Creates new Variant as boolean.

 

class method variantWithBoolean(aValue: Boolean): VariantType

 

static VariantType variantWithBoolean(Boolean aValue)

Parameters:

  • aValue: Given boolean value.

variantWithString

Creates new Variant as string.

 

class method variantWithString(aValue: String): VariantType

 

static VariantType variantWithString(String aValue)

Parameters:

  • aValue: Given String value.

 

constructor

Creates EmptyVariant.

 

constructor

 

VariantType()

constructor (VariantTypeCode, Object)

Creates VariantType with given type and value.

 

constructor(aDataType: VariantTypeCode; aValue: Object)

 

VariantType(VariantTypeCode aDataType, Object aValue)

Parameters:


constructor (Object)

Creates VariantType with given object.

 

constructor(aValue: Object)

 

VariantType(Object aValue)

Parameters:

  • aValue: Given object.

getItemAtIndex

Returns object in a specific position.

 

method getItemAtIndex(anIndex: Integer): VariantType

 

VariantType getItemAtIndex(Integer anIndex)

Parameters:

  • anIndex: Given position.

setArrayLength

Calls to create variant array type, or increase/decrease array size.

 

method setArrayLength(aLength: Integer; aDataType: VariantTypeCode)

 

void setArrayLength(Integer aLength, VariantTypeCode aDataType)

Parameters:


setEmpty

Sets variant as empty.

 

method setEmpty

 

void setEmpty()

setItem

Sets specific object to specific index in an Variant array.

 

method setItem(anItem: VariantType; anIndex: Integer)

 

void setItem(VariantType anItem, Integer anIndex)

Parameters:

  • anItem: Given value.
  • anIndex: Given position.

setNull

Sets variant as null.

 

method setNull

 

void setNull()