Interface IDfValue
Value objects provide a convenient way to store variant values, which are values storing the variant datatype. The variant datatype is used to declare variables that can hold one of many different types of data, as in the following example in Visual Basic:
DfValue[] vals = new DfValue[num_attrs];
for (int j = 0; j < num_attrs; j++)
{
vals[j] = myobject.getValue(myobject.getAttr(j).getName());
}
Note that value objects are immutable. Refer to the DocbasicTM User's Guide for more information about the variant datatype. Refer to the Server Reference Manual for more information about value objects.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Represents the boolean datatype.static final int
Represents the double datatype.static final int
Represents the ID datatype.static final int
Represents the integer datatype.static final int
Represents the string datatype.static final int
Represents the time datatype.static final int
Represents an undefined datatype. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the contents of a value object as a boolean.double
asDouble()
Returns the contents of a value object as a double.asId()
Returns the contents of a value object as anIDfId
interface.int
Returns the contents of a value object as a integer.asString()
Returns the contents of a value object as a string.asTime()
Returns the contents of a value object as anIDfTime
interface.int
Indicates whether the value stored in the calling value object is less than, equal to, or greater than the value stored in a user-supplied value object.boolean
Indicates whether the value stored in the calling value object matches the value in a user-supplied value object.int
Returns the datatype of a value stored in a value object.
-
Field Details
-
DF_BOOLEAN
static final int DF_BOOLEANRepresents the boolean datatype.- See Also:
-
DF_INTEGER
static final int DF_INTEGERRepresents the integer datatype.- See Also:
-
DF_STRING
static final int DF_STRINGRepresents the string datatype.- See Also:
-
DF_ID
static final int DF_IDRepresents the ID datatype.- See Also:
-
DF_TIME
static final int DF_TIMERepresents the time datatype.- See Also:
-
DF_DOUBLE
static final int DF_DOUBLERepresents the double datatype.- See Also:
-
DF_UNDEFINED
static final int DF_UNDEFINEDRepresents an undefined datatype.- See Also:
-
-
Method Details
-
asString
String asString()Returns the contents of a value object as a string.- Returns:
- the string value
-
asInteger
int asInteger()Returns the contents of a value object as a integer.This method returns 0 if the value cannot be converted to an integer.
- Returns:
- the integer value
-
asBoolean
boolean asBoolean()Returns the contents of a value object as a boolean.This method returns false if the value cannot be converted to a boolean, such as integers other than 0 or 1.
- Returns:
- the boolean value
-
asDouble
double asDouble()Returns the contents of a value object as a double.This method returns 0 if the value cannot be converted to a double, such as a string.
- Returns:
- the double value
-
asTime
IDfTime asTime()Returns the contents of a value object as anIDfTime
interface.- Returns:
- the
IDfTime
interface
-
asId
IDfId asId()Returns the contents of a value object as anIDfId
interface.- Returns:
- the
IDfId
interface; Note that if the underlying value is not an object ID, the return value has no meaning.
-
getDataType
int getDataType()Returns the datatype of a value stored in a value object.- Returns:
- the datatype of the value stored in the value object;
The following list explains the meaning of all possible returned integers:
Value Datatype 0 Boolean 1 Integer 2 String 3 ID 4 Time, or date 5 Double 6 Undefined
-
equals
Indicates whether the value stored in the calling value object matches the value in a user-supplied value object.- Overrides:
equals
in classObject
- Parameters:
value
- an interface to the object containing the value that you want to test; Valid arguments areIDfValue
,IDfID
,IDfTime
, and the following Java objects: Boolean, Integer, String, and Double.- Returns:
TRUE
if the values are the same;FALSE
if they are not.
-
compareTo
Indicates whether the value stored in the calling value object is less than, equal to, or greater than the value stored in a user-supplied value object.The following list explains the meaning of all return values:
Value Meaning -1 Less Than 0 Equal To 1 Greater Than
- Parameters:
value
- anIDfValue
interface to the object containing the value that you want to test against- Returns:
- -1 if the value stored in the calling value object is less than the value stored in the user-supplied value object; 0 if the two values are equal; 1 if the value stored in the calling value object is greater than the value stored in the user-supplied value object
- Throws:
DfException
- if the types stored in the value objects do not match or if this method is called on a value of type boolean
-