org.freehep.util
Class Value
- java.lang.Object
-
- org.freehep.util.Value
-
public class Value extends java.lang.ObjectA class that can represent any Java object or primitive. Unlike the built-in primitive proxies (Double, Integer etc) it is mutable. It is used to allow values to be used without needing overloaded methods for each primitive type, and without the overhead of object creation/deletion. When a value is returned by an Object method it should be assumed to be valid only until the next method call to that Object. The use of Value should be avoided in multi-threaded environments.
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.ClassTYPE_BOOLEANstatic java.lang.ClassTYPE_BYTEstatic java.lang.ClassTYPE_CHARstatic java.lang.ClassTYPE_DATEstatic java.lang.ClassTYPE_DOUBLEstatic java.lang.ClassTYPE_FLOATstatic java.lang.ClassTYPE_INTEGERstatic java.lang.ClassTYPE_LONGstatic java.lang.ClassTYPE_SHORTstatic java.lang.ClassTYPE_STRING
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description ValuefromExternal(java.lang.String external)Set to value from the external respresentationbooleangetBoolean()Get the boolean value.bytegetByte()Get the byte value.chargetChar()Get the char value.java.util.DategetDate()Get the Date value.doublegetDouble()Get the double value.floatgetFloat()Get the float value.intgetInt()Get the integer value.longgetLong()Get the long value.java.lang.ObjectgetObject()Get the Object value.shortgetShort()Get the short value.java.lang.StringgetString()Get the String value.java.lang.ClassgetType()Get the Value's typeValueset(boolean val)Set the Value's internal value to a boolean.Valueset(byte val)Set the Value's internal value to a byte.Valueset(char val)Set the Value's internal value to a char.Valueset(java.util.Date val)Set the Value's internal value to a Date.Valueset(double val)Set the Value's internal value to a double.Valueset(float val)Set the Value's internal value to a float.Valueset(int val)Set the Value's internal value to an integer.Valueset(long val)Set the Value's internal value to a long.Valueset(java.lang.Object val)Set the Value's internal value to an Object.Valueset(short val)Set the Value's internal value to a short.Valueset(java.lang.String val)Set the Value's internal value to a String.ValuesetValue(Value v)java.lang.StringtoExternal()Returns an external representation of this valuejava.lang.StringtoString()Get the String value.
-
-
-
Field Detail
-
TYPE_INTEGER
public static final java.lang.Class TYPE_INTEGER
-
TYPE_SHORT
public static final java.lang.Class TYPE_SHORT
-
TYPE_LONG
public static final java.lang.Class TYPE_LONG
-
TYPE_FLOAT
public static final java.lang.Class TYPE_FLOAT
-
TYPE_DOUBLE
public static final java.lang.Class TYPE_DOUBLE
-
TYPE_BOOLEAN
public static final java.lang.Class TYPE_BOOLEAN
-
TYPE_BYTE
public static final java.lang.Class TYPE_BYTE
-
TYPE_CHAR
public static final java.lang.Class TYPE_CHAR
-
TYPE_STRING
public static final java.lang.Class TYPE_STRING
-
TYPE_DATE
public static final java.lang.Class TYPE_DATE
-
-
Constructor Detail
-
Value
public Value()
-
Value
public Value(Value v)
-
-
Method Detail
-
getType
public java.lang.Class getType()
Get the Value's type- Returns:
- The Class of this Value.
-
set
public Value set(int val)
Set the Value's internal value to an integer.- Parameters:
val- The integer value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(short val)
Set the Value's internal value to a short.- Parameters:
val- The short value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(long val)
Set the Value's internal value to a long.- Parameters:
val- The long value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(float val)
Set the Value's internal value to a float.- Parameters:
val- The float value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(double val)
Set the Value's internal value to a double.- Parameters:
val- The double value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(boolean val)
Set the Value's internal value to a boolean.- Parameters:
val- The boolean value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(byte val)
Set the Value's internal value to a byte.- Parameters:
val- The byte value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(char val)
Set the Value's internal value to a char.- Parameters:
val- The char value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(java.lang.String val)
Set the Value's internal value to a String.- Parameters:
val- The String value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(java.util.Date val)
Set the Value's internal value to a Date.- Parameters:
val- The Date value.- Returns:
- The Value object with the given internal value.
-
set
public Value set(java.lang.Object val)
Set the Value's internal value to an Object.- Parameters:
val- The Object value.- Returns:
- The Value object with the given internal value.
-
getInt
public int getInt()
Get the integer value.- Returns:
- The int value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getShort
public short getShort()
Get the short value.- Returns:
- The short value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getLong
public long getLong()
Get the long value.- Returns:
- The long value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getFloat
public float getFloat()
Get the float value.- Returns:
- The float value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getDouble
public double getDouble()
Get the double value.- Returns:
- The double value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getBoolean
public boolean getBoolean()
Get the boolean value.- Returns:
- The boolean value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getByte
public byte getByte()
Get the byte value.- Returns:
- The byte value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getChar
public char getChar()
Get the char value.- Returns:
- The char value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getString
public java.lang.String getString()
Get the String value.- Returns:
- The String representation of the internal value.
-
getDate
public java.util.Date getDate()
Get the Date value.- Returns:
- The Date value.
- Throws:
A- ClassCastException is thrown if this Value has incompatible type.
-
getObject
public java.lang.Object getObject()
Get the Object value.- Returns:
- The Object value.
-
toString
public java.lang.String toString()
Get the String value.- Overrides:
toStringin classjava.lang.Object- Returns:
- The String representation of the internal value.
-
toExternal
public java.lang.String toExternal()
Returns an external representation of this value
-
fromExternal
public Value fromExternal(java.lang.String external) throws java.lang.IllegalArgumentException
Set to value from the external respresentation- Throws:
java.lang.IllegalArgumentException
-
-
DMelt 3.0 © DataMelt by jWork.ORG