FreeHEP API
Version current

org.freehep.util
Class Value

java.lang.Object
  extended byorg.freehep.util.Value

public class Value
extends Object

A 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.

Version:
$Id: Value.java,v 1.5 2004/05/19 21:44:26 duns Exp $
Author:
tonyj
Source Code:
Value.java

Field Summary
static Class TYPE_BOOLEAN
           
static Class TYPE_BYTE
           
static Class TYPE_CHAR
           
static Class TYPE_DATE
           
static Class TYPE_DOUBLE
           
static Class TYPE_FLOAT
           
static Class TYPE_INTEGER
           
static Class TYPE_LONG
           
static Class TYPE_SHORT
           
static Class TYPE_STRING
           
 
Constructor Summary
Value()
           
Value(Value v)
           
 
Method Summary
 Value fromExternal(String external)
          Set to value from the external respresentation
 boolean getBoolean()
          Get the boolean value.
 byte getByte()
          Get the byte value.
 char getChar()
          Get the char value.
 Date getDate()
          Get the Date value.
 double getDouble()
          Get the double value.
 float getFloat()
          Get the float value.
 int getInt()
          Get the integer value.
 long getLong()
          Get the long value.
 Object getObject()
          Get the Object value.
 short getShort()
          Get the short value.
 String getString()
          Get the String value.
 Class getType()
          Get the Value's type
 Value set(boolean val)
          Set the Value's internal value to a boolean.
 Value set(byte val)
          Set the Value's internal value to a byte.
 Value set(char val)
          Set the Value's internal value to a char.
 Value set(Date val)
          Set the Value's internal value to a Date.
 Value set(double val)
          Set the Value's internal value to a double.
 Value set(float val)
          Set the Value's internal value to a float.
 Value set(int val)
          Set the Value's internal value to an integer.
 Value set(long val)
          Set the Value's internal value to a long.
 Value set(Object val)
          Set the Value's internal value to an Object.
 Value set(short val)
          Set the Value's internal value to a short.
 Value set(String val)
          Set the Value's internal value to a String.
 String toExternal()
          Returns an external representation of this value
 String toString()
          Get the String value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_INTEGER

public static final Class TYPE_INTEGER

TYPE_SHORT

public static final Class TYPE_SHORT

TYPE_LONG

public static final Class TYPE_LONG

TYPE_FLOAT

public static final Class TYPE_FLOAT

TYPE_DOUBLE

public static final Class TYPE_DOUBLE

TYPE_BOOLEAN

public static final Class TYPE_BOOLEAN

TYPE_BYTE

public static final Class TYPE_BYTE

TYPE_CHAR

public static final Class TYPE_CHAR

TYPE_STRING

public static final Class TYPE_STRING

TYPE_DATE

public static final Class TYPE_DATE
Constructor Detail

Value

public Value()

Value

public Value(Value v)
Method Detail

getType

public 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(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(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(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 String getString()
Get the String value.

Returns:
The String representation of the internal value.

getDate

public Date getDate()
Get the Date value.

Returns:
The Date value.
Throws:
A - ClassCastException is thrown if this Value has incompatible type.

getObject

public Object getObject()
Get the Object value.

Returns:
The Object value.

toString

public String toString()
Get the String value.

Returns:
The String representation of the internal value.

toExternal

public String toExternal()
Returns an external representation of this value


fromExternal

public Value fromExternal(String external)
                   throws IllegalArgumentException
Set to value from the external respresentation

Throws:
IllegalArgumentException

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.