|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.upc.dama.dex.core.Value
public class Value
Typed value representation.
It stores a value and its type. Also, there is a special case which is the NULL value.
| Field Summary | |
|---|---|
static short |
BOOL
Boolean data type representation. |
static short |
DOUBLE
Double data type representation. |
static short |
INT
Integer data type representation. |
static short |
LONG
Long data type representation. |
static short |
NULL
NULL data type representation. |
static short |
STRING
String data type representation. |
static int |
STRING_MAX_LENGTH
Maximum length for String values. |
static short |
TEXT
Text data type representation. |
static short |
TIMESTAMP
Timestamp data type representation. |
| Constructor Summary | |
|---|---|
Value()
Creates a new instance of Value. |
|
Value(boolean v)
Creates a new instance of Value. |
|
Value(java.util.Calendar v)
Creates a new instance of Value. |
|
Value(double v)
Creates a new instance of Value. |
|
Value(int v)
Creates a new instance of Value. |
|
Value(long v)
Creates a new instance of Value. |
|
Value(java.lang.Object object)
Creates a new instance of Value. |
|
Value(java.lang.String v)
Creates a new instance of Value. |
|
Value(TextStream v)
Creates a new instance of Value. |
|
| Method Summary | |
|---|---|
short |
compare(Value value)
Compares with the given value. |
boolean |
equals(java.lang.Object obj)
Value value equals comparisson. |
java.lang.Object |
get()
Gets the value. |
boolean |
getBool()
Gets the value as a Boolean. |
double |
getDouble()
Gets the value as a Double. |
int |
getInt()
Gets the value as an Integer. |
long |
getLong()
Gets the value as a Long. |
java.lang.String |
getString()
Gets the value as a String. |
TextStream |
getTextStream()
Gets the value as a TextStream. |
java.util.Calendar |
getTimestamp()
Gets the value as a Calendar. |
long |
getTimestampValue()
Gets the value as a Timestamp. |
short |
getType()
Gets the data type. |
static short |
getType(java.lang.String typename)
Gets the short representation of a data type. |
static java.lang.String |
getTypeName(short type)
Gets a String representation of a data type. |
int |
hashCode()
Gets the hash code of the Value |
boolean |
isNull()
Gets whether the data type is Value.NULL or not. |
Value |
setBool(boolean value)
Sets a Boolean value. |
Value |
setDouble(double value)
Sets a Double value. |
Value |
setInt(int value)
Sets an Integer value. |
Value |
setLong(long value)
Sets a Long value. |
Value |
setNull()
Sets a NULL value. |
Value |
setString(java.lang.String value)
Sets a String value. |
Value |
setTextStream(TextStream tstrm)
Sets a Text value. |
Value |
setTimestamp(java.util.Calendar value)
Sets a Timestamp value. |
java.lang.String |
toString()
Gets a string representation. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int STRING_MAX_LENGTH
public static final short NULL
public static final short INT
public static final short STRING
public static final short DOUBLE
public static final short BOOL
public static final short TIMESTAMP
public static final short LONG
public static final short TEXT
| Constructor Detail |
|---|
public Value()
Value.
It creates a NULL value.
Value.isNull()public Value(int v)
Value.
It creates an Integer value.
v - Assigned value.public Value(long v)
Value.
It creates a Long value.
v - Assigned value.public Value(java.lang.String v)
Value.
It creates a String value.
v - Assigned value.public Value(boolean v)
Value.
It creates a Boolean value.
v - Assigned value.public Value(double v)
Value.
It creates a Double value.
v - Assigned value.public Value(java.util.Calendar v)
Value.
It creates a Timestamp value.
v - Assigned value.public Value(TextStream v)
Value.
It creates a Text value.
v - Assgined value.public Value(java.lang.Object object)
Value.
It creates an instance from a Java Object.
If object is an instance of Integer
then it creates an Integer value, if it is an instance of
Long then it creates a Long value, if it is an instance
of Calendar then it creates a Timestamp value, and so on.
object - Assigned value.
java.lang.IllegalArgumentException - if object is not a valid type
java.lang.IllegalArgumentException - if object is a string and ((String)object).length() grater than STRING_MAX_LENGTH| Method Detail |
|---|
public java.lang.Object get()
If it is a NULL value, then a null
pointer is is returned.
null.public java.lang.String toString()
If the type is Value.NULL, then a "null"
pointer is returned.
toString in class java.lang.Objectpublic short getType()
The data type can be Value.NULL, Value.INT,
Value.STRING, Value.DOUBLE, Value.BOOL, Value.TIMESTAMP,
Value.LONG or Value.TEXT.
public Value setNull()
It changes the data type to Value.NULL and the value
to null.
this).public boolean isNull()
Value.NULL or not.
true if the data type is
Value.NULL, false otherwise.public Value setInt(int value)
It changes the data type to Value.INT and the value
to value.
this).public int getInt()
java.lang.ClassCastException - if value type is not Value.INTpublic Value setString(java.lang.String value)
It changes the data type to Value.STRING and the value
to value.
this).
java.lang.IllegalArgumentException - if value.length() grater than STRING_MAX_LENGTHpublic java.lang.String getString()
Unpredicted result if the data type of the value is not
Value.STRING.
public Value setDouble(double value)
It changes the data type to Value.DOUBLE and the value
to value.
this).public double getDouble()
java.lang.ClassCastException - if Value type is not Value.DOUBLEpublic Value setBool(boolean value)
It changes the data type to Value.BOOL and the value
to value.
this).public boolean getBool()
java.lang.ClassCastException - if type is not Value.BOOLpublic Value setTimestamp(java.util.Calendar value)
It changes the data type to Value.TIMESTAMP and the value
to value.
this).Calendarpublic java.util.Calendar getTimestamp()
java.lang.ClassCastException - if Value type is not Value.TIMESTAMPCalendarpublic long getTimestampValue()
java.lang.ClassCastException - if Value type is not Value.TIMESTAMPCalendar.getTimeInMillis()public Value setLong(long value)
It changes the data type to Value.LONG and the value
to value.
this).public long getLong()
java.lang.ClassCastException - if type is not Value.LONGpublic Value setTextStream(TextStream tstrm)
It changes the data type to Value.TEXT and the value
to value.
this).TextStreampublic TextStream getTextStream()
java.lang.ClassCastException - if Value type is not Value.TEXTpublic short compare(Value value)
It works if and only if two values have the same data type.
For boolean types, false is considered smaller
than true.
For text types, this operation has no sense so. Thus, if two
values with a text data type are set to be compared, an
IllegalStateException will be thrown.
value - Value to be compared to.
-1 if the value of the calling instance
is smaller than the given value, 0 if they are equal
to each other and 1 if the value of the calling
instance is greater than the given value.public static java.lang.String getTypeName(short type)
type - It must be Value.NULL, Value.INT,
Value.STRING, Value.DOUBLE, Value.BOOL, Value.TIMESTAMP,
or Value.LONG.
public static short getType(java.lang.String typename)
The comparision of the given String is case insensitive.
typename - String data type representation.
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - object to compare with
true if both objects have the same type and valeu,
false otherwise
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||