com.sparsity.sparksee.gdb
Class Value

java.lang.Object
  extended by com.sparsity.sparksee.gdb.Value

public class Value
extends java.lang.Object

Value class.

It is a container which stores a value and its data type (domain). A Value can be NULL.

Author:
Sparsity Technologies http://www.sparsity-technologies.com

Field Summary
static int MaxLengthString
          Maximum number of characters allowed for a String.
 
Constructor Summary
Value()
          Creates a new instance.
Value(Value v)
          Copy constructor.
 
Method Summary
 int compare(Value v)
          Compares with the given Value.
 int compareTo(java.lang.Object v)
          See compare().
 int compareTo(Value v)
          See compare().
 boolean equals(java.lang.Object other)
          
 boolean equals(Value v)
          Compares with the given Value.
 boolean getBoolean()
          Gets Boolean Value.
 DataType getDataType()
          Gets the DataType.
 double getDouble()
          Gets Double Value.
 int getInteger()
          Gets Integer Value.
 long getLong()
          Gets Long Value.
 long getOID()
          Gets OID Value.
 java.lang.String getString()
          Gets String Value.
 long getTimestamp()
          Gets Timestamp Value.
 java.util.Calendar getTimestampAsCalendar()
          Gets the Value as a Calendar instance.
 java.util.Date getTimestampAsDate()
          Gets the Value as a Date instance.
 int hashCode()
          
 boolean isNull()
          Gets if this is a NULL Value.
 Value set(Value v)
          Sets the Value.
 Value setBoolean(boolean v)
          Sets the Value.
 void setBooleanVoid(boolean v)
          Sets the Value.
 Value setDouble(double v)
          Sets the Value.
 void setDoubleVoid(double v)
          Sets the Value.
 Value setInteger(int v)
          Sets the Value.
 void setIntegerVoid(int v)
          Sets the Value.
 Value setLong(long v)
          Sets the Value.
 void setLongVoid(long v)
          Sets the Value.
 Value setNull()
          Sets the Value to NULL.
 void setNullVoid()
          Sets the Value to NULL.
 Value setOID(long v)
          Sets the Value.
 void setOIDVoid(long v)
          Sets the OID Value.
 Value setString(java.lang.String v)
          Sets the Value.
 void setStringVoid(java.lang.String v)
          Sets the Value.
 Value setText(TextStream v)
          Sets the Value.
 Value setTimestamp(java.util.Calendar v)
          Sets the Value.
 Value setTimestamp(java.util.Date v)
          Sets the Value.
 Value setTimestamp(int year, int month, int day, int hour, int minutes, int seconds, int millisec)
          Sets the Value.
 void setTimestampVoid(int year, int month, int day, int hour, int minutes, int seconds, int millisecs)
          Sets the Value.
 void setTimestampVoid(long v)
          Sets the Value.
 void setVoid(Value v)
          Sets the Value.
 java.lang.String toString()
          Gets a String representation of the Value.
 java.lang.String toString(java.lang.String str)
          Gets a string representation of the Value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MaxLengthString

public static int MaxLengthString
Maximum number of characters allowed for a String.

Constructor Detail

Value

public Value(Value v)
Copy constructor.

Parameters:
v - [in] Value to be copied.

Value

public Value()
Creates a new instance.

It creates a NULL Value.

Method Detail

setLongVoid

public void setLongVoid(long v)
Sets the Value.

Parameters:
v - [in] New Long value.

getTimestampAsCalendar

public java.util.Calendar getTimestampAsCalendar()
Gets the Value as a Calendar instance.

Returns:
The returning Calendar instance.

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object
Parameters:
other - null

getOID

public long getOID()
Gets OID Value.

This must be an non-NULL OID Value.

Returns:
The OID Value.

set

public Value set(Value v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

setString

public Value setString(java.lang.String v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

setBooleanVoid

public void setBooleanVoid(boolean v)
Sets the Value.

Parameters:
v - [in] New Boolean value.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

compare

public int compare(Value v)
Compares with the given Value.

It does not work for Text or if given Value objects does not have the same DataType.

Parameters:
v - Given value to compare to.
Returns:
0 if this Value is equal to the given one; a value less than 0 if this Value is less than the given one; and a value greater than 0 if this Value is greater than the given one.

setDoubleVoid

public void setDoubleVoid(double v)
Sets the Value.

Parameters:
v - [in] New Double value.

setText

public Value setText(TextStream v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

setBoolean

public Value setBoolean(boolean v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

setTimestamp

public Value setTimestamp(java.util.Calendar v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

getBoolean

public boolean getBoolean()
Gets Boolean Value.

This must be a non-NULL Boolean Value.

Returns:
The Boolean Value.

setTimestampVoid

public void setTimestampVoid(long v)
Sets the Value.

Parameters:
v - [in] New Timestamp value.

setDouble

public Value setDouble(double v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

compareTo

public int compareTo(Value v)
See compare().

Parameters:
v - null

setNullVoid

public void setNullVoid()
Sets the Value to NULL.


setOIDVoid

public void setOIDVoid(long v)
Sets the OID Value.

Parameters:
v - [in] New OID value.

getDataType

public DataType getDataType()
Gets the DataType.

Value cannot be NULL.

Returns:
The DataType.

setLong

public Value setLong(long v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

getTimestampAsDate

public java.util.Date getTimestampAsDate()
Gets the Value as a Date instance.

Returns:
The returning Date instance.

getString

public java.lang.String getString()
Gets String Value.

This must be a non-NULL String Value.

Returns:
The String Value.

isNull

public boolean isNull()
Gets if this is a NULL Value.

Returns:
TRUE if this is a NULL Value, FALSE otherwise.

setTimestamp

public Value setTimestamp(int year,
                          int month,
                          int day,
                          int hour,
                          int minutes,
                          int seconds,
                          int millisec)
Sets the Value.

Parameters:
year - The year (>=1970).
month - The month ([1..12]).
day - The day of the month ([1..31]).
hour - The hour ([0..23]).
minutes - The minutes ([0..59]).
seconds - The seconds ([0..59]).
millisec - The milliseconds ([0..999]).
Returns:
The calling instance.

setTimestampVoid

public void setTimestampVoid(int year,
                             int month,
                             int day,
                             int hour,
                             int minutes,
                             int seconds,
                             int millisecs)
Sets the Value.

Parameters:
year - [in] The year (>=1970).
month - [in] The month ([1..12]).
day - [in] The of the month ([1..31]).
hour - [in] The hour ([0..23]).
minutes - [in] The minutes ([0..59]).
seconds - [in] The seconds ([0..59]).
millisecs - [in] The milliseconds ([0..999]).

compareTo

public int compareTo(java.lang.Object v)
See compare().

This just works if the given object is a Value instance.

Parameters:
v - null

equals

public boolean equals(Value v)
Compares with the given Value.

It does not work for Text or if given Value objects does not have the same DataType.

Parameters:
v - Given value to compare to.
Returns:
TRUE if this Value is equal to the given one; FALSE otherwise.

getDouble

public double getDouble()
Gets Double Value.

This must be a non-NULL Double Value.

Returns:
The Double Value.

setIntegerVoid

public void setIntegerVoid(int v)
Sets the Value.

Parameters:
v - [in] New Integer value.

toString

public java.lang.String toString(java.lang.String str)
Gets a string representation of the Value.

It does not work for Text.

Parameters:
str - String to be used. It is cleared and set with the string representation of the Value.
Returns:
The given string which has been updated.

setVoid

public void setVoid(Value v)
Sets the Value.

Parameters:
v - [in] New value.

setNull

public Value setNull()
Sets the Value to NULL.

Returns:
The calling instance.

setOID

public Value setOID(long v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

setStringVoid

public void setStringVoid(java.lang.String v)
Sets the Value.

Parameters:
v - [in] New String value.

getLong

public long getLong()
Gets Long Value.

This must be a non-NULL Long Value.

Returns:
The Long Value.

toString

public java.lang.String toString()
Gets a String representation of the Value.

It does not work for Text Value instances.

Overrides:
toString in class java.lang.Object

getTimestamp

public long getTimestamp()
Gets Timestamp Value.

This must be a non-NULL Timestamp Value.

Returns:
The Timestamp Value.

setInteger

public Value setInteger(int v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

setTimestamp

public Value setTimestamp(java.util.Date v)
Sets the Value.

Parameters:
v - New value.
Returns:
The calling instance.

getInteger

public int getInteger()
Gets Integer Value.

This must be a non-NULL Integer Value.

Returns:
The Integer Value.