com.amx.duet.tools.lang
Class ObjectRef

java.lang.Object
  extended bycom.amx.duet.tools.lang.ObjectRef
Direct Known Subclasses:
Marshall

public class ObjectRef
extends java.lang.Object

An object reference class used to convert objects from one value or data type to another. This class was created to handle parameter pass by reference values.

Since:
AMXTools 1.0.0
Version:
1.0.0

Constructor Summary
ObjectRef(boolean b)
          Creates an object representation of the boolean argument.
ObjectRef(byte b)
          Creates an object representation of the byte argument.
ObjectRef(char c)
          Creates an object representation of the char argument.
ObjectRef(double d)
          Creates an object representation of the double argument.
ObjectRef(float f)
          Creates an object representation of the float argument.
ObjectRef(int i)
          Creates an object representation of the int argument.
ObjectRef(long l)
          Creates an object representation of the long argument.
ObjectRef(java.lang.Object o)
          Stores a copy of the Object argument.
ObjectRef(java.lang.Object o, ObjectType refType)
          Stores a copy of the Object argument as the ObjectType passed in.
ObjectRef(ObjectType refType)
          Creates an empty object representation of the type of ObjectType passed in.
ObjectRef(short s)
          Creates an object representation of the short argument.
ObjectRef(java.lang.String str)
          Creates an object representation of the String argument.
 
Method Summary
 boolean booleanValue()
          Returns the boolean value stored within this object.
 byte byteValue()
          Returns the byte value stored within this object.
 char charValue()
          Returns the char value stored within this object.
 double doubleValue()
          Returns the double value stored within this object.
 boolean equals(java.lang.Object obj)
           
 float floatValue()
          Returns the float value stored within this object.
 ObjectType getType()
          Returns the object type for the currently stored object.
 java.lang.Object getValue()
          Returns the object representation of the value stored in this object.
 int intValue()
          Returns the int value stored within this object.
 long longValue()
          Returns the long value stored within this object.
 short shortValue()
          Returns the short value stored within this object.
 java.lang.String stringValue()
          Returns the String value stored within this object.
 boolean toBoolean()
          Converts the stored value to a boolean representation and returns the new value.
 byte toByte()
          Converts the stored value to a byte representation and returns the new value.
 char toChar()
          Converts the stored value to a char representation and returns the new value.
 double toDouble()
          Converts the stored value to a double representation and returns the new value.
 float toFloat()
          Converts the stored value to a float representation and returns the new value.
 int toInt()
          Converts the stored value to a int representation and returns the new value.
 long toLong()
          Converts the stored value to a long representation and returns the new value.
 short toShort()
          Converts the stored value to a short representation and returns the new value.
 java.lang.String toString()
           
 java.lang.Object valueOf(boolean b)
          Stores and returns the object representation of the boolean argument.
 java.lang.Object valueOf(byte b)
          Stores and returns the object representation of the byte argument.
 java.lang.Object valueOf(char c)
          Stores and returns the object representation of the char argument.
 java.lang.Object valueOf(double d)
          Stores and returns the object representation of the double argument.
 java.lang.Object valueOf(float f)
          Stores and returns the object representation of the floag argument.
 java.lang.Object valueOf(int i)
          Stores and returns the object representation of the int argument.
 java.lang.Object valueOf(long l)
          Stores and returns the object representation of the long argument.
 java.lang.Object valueOf(java.lang.Object o)
          Stores and returns the Object argument.
 java.lang.Object valueOf(java.lang.Object o, ObjectType refType)
          Stores and returns the Object argument as the ObjectType passed in.
 java.lang.Object valueOf(short s)
          Stores and returns the object representation of the short argument.
 java.lang.Object valueOf(java.lang.String str)
          Stores and returns the object representation of the String argument.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ObjectRef

public ObjectRef(boolean b)
Creates an object representation of the boolean argument.

Parameters:
b - a boolean.

ObjectRef

public ObjectRef(byte b)
Creates an object representation of the byte argument.

Parameters:
b - a byte.

ObjectRef

public ObjectRef(char c)
Creates an object representation of the char argument.

Parameters:
c - a char.

ObjectRef

public ObjectRef(short s)
Creates an object representation of the short argument.

Parameters:
s - a short.

ObjectRef

public ObjectRef(int i)
Creates an object representation of the int argument.

Parameters:
i - a int.

ObjectRef

public ObjectRef(long l)
Creates an object representation of the long argument.

Parameters:
l - a long.

ObjectRef

public ObjectRef(float f)
Creates an object representation of the float argument.

Parameters:
f - a float.

ObjectRef

public ObjectRef(double d)
Creates an object representation of the double argument.

Parameters:
d - a double.

ObjectRef

public ObjectRef(java.lang.String str)
Creates an object representation of the String argument.

Parameters:
str - a String.

ObjectRef

public ObjectRef(java.lang.Object o)
Stores a copy of the Object argument.

Parameters:
o - an Object.

ObjectRef

public ObjectRef(java.lang.Object o,
                 ObjectType refType)
Stores a copy of the Object argument as the ObjectType passed in.

Parameters:
o - an Object.
refType - the ObjectType that the object is assigned as.

ObjectRef

public ObjectRef(ObjectType refType)
Creates an empty object representation of the type of ObjectType passed in.

Parameters:
refType - the ObjectType that the object is assigned as.
Throws:
java.lang.UnsupportedOperationException - if the object type passed in is not supported.
Method Detail

valueOf

public java.lang.Object valueOf(boolean b)
Stores and returns the object representation of the boolean argument.

Parameters:
b - a boolean.
Returns:
The boolean value created as a Boolean object and cast to an Object.

valueOf

public java.lang.Object valueOf(byte b)
Stores and returns the object representation of the byte argument.

Parameters:
b - a byte.
Returns:
The byte value created as a Byte object and cast to an Object.

valueOf

public java.lang.Object valueOf(char c)
Stores and returns the object representation of the char argument.

Parameters:
c - a char.
Returns:
The char value created as a Character object and cast to an Object.

valueOf

public java.lang.Object valueOf(short s)
Stores and returns the object representation of the short argument.

Parameters:
s - a short.
Returns:
The short value created as a Short object and cast to an Object.

valueOf

public java.lang.Object valueOf(int i)
Stores and returns the object representation of the int argument.

Parameters:
i - an int.
Returns:
The int value created as a Integer object and cast to an Object.

valueOf

public java.lang.Object valueOf(long l)
Stores and returns the object representation of the long argument.

Parameters:
l - a long.
Returns:
The long value created as a Long object and cast to an Object.

valueOf

public java.lang.Object valueOf(float f)
Stores and returns the object representation of the floag argument.

Parameters:
f - a float.
Returns:
The float value created as a Float object and cast to an Object.

valueOf

public java.lang.Object valueOf(double d)
Stores and returns the object representation of the double argument.

Parameters:
d - a double.
Returns:
The double value created as a Double object and cast to an Object.

valueOf

public java.lang.Object valueOf(java.lang.String str)
Stores and returns the object representation of the String argument.

Parameters:
str - a String.
Returns:
The String value cast to an Object.

valueOf

public java.lang.Object valueOf(java.lang.Object o)
Stores and returns the Object argument.

Parameters:
o - an Object.
Returns:
The Object argument passed it.

valueOf

public java.lang.Object valueOf(java.lang.Object o,
                                ObjectType refType)
Stores and returns the Object argument as the ObjectType passed in.

Parameters:
o - an Object.
refType -
Returns:
The Object argument passed it.
Throws:
java.lang.UnsupportedOperationException - if the object type passed in is not supported.

booleanValue

public boolean booleanValue()
Returns the boolean value stored within this object.

Returns:
If this object was created from a boolean value, then that value will be returned. Otherwise, false will be returned.

byteValue

public byte byteValue()
Returns the byte value stored within this object.

Returns:
If this object was created from a byte value, then that value will be returned. Otherwise, 0 will be returned.

charValue

public char charValue()
Returns the char value stored within this object.

Returns:
If this object was created from a char value, then that value will be returned. Otherwise, 0 will be returned.

shortValue

public short shortValue()
Returns the short value stored within this object.

Returns:
If this object was created from a short value, then that value will be returned. Otherwise, 0 will be returned.

intValue

public int intValue()
Returns the int value stored within this object.

Returns:
If this object was created from a int value, then that value will be returned. Otherwise, 0 will be returned.

longValue

public long longValue()
Returns the long value stored within this object.

Returns:
If this object was created from a long value, then that value will be returned. Otherwise, 0 will be returned.

floatValue

public float floatValue()
Returns the float value stored within this object.

Returns:
If this object was created from a float value, then that value will be returned. Otherwise, 0 will be returned.

doubleValue

public double doubleValue()
Returns the double value stored within this object.

Returns:
If this object was created from a double value, then that value will be returned. Otherwise, 0 will be returned.

stringValue

public java.lang.String stringValue()
Returns the String value stored within this object.

Returns:
If this object was created from a String value, then that value will be returned. Otherwise, an empty string will be returned.

getValue

public java.lang.Object getValue()
Returns the object representation of the value stored in this object.

Returns:
The Object stored in this object.

getType

public ObjectType getType()
Returns the object type for the currently stored object.

Returns:
ObjectType representing the type of object stored.

equals

public boolean equals(java.lang.Object obj)

toString

public java.lang.String toString()

toBoolean

public boolean toBoolean()
Converts the stored value to a boolean representation and returns the new value.

Returns:
The converted boolean value. If the stored value is equal to "true" or a value other than 0, the return value will be true. Otherwise, the return value should be false.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.

toByte

public byte toByte()
Converts the stored value to a byte representation and returns the new value.

Returns:
The converted byte value. If the stored value is equal to "true", the return value will be 1. If the value could not be converted the return value will be 0. Otherwise, the return value should be a value between Byte.MIN_VALUE and Byte.MAX_VALUE.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.

toChar

public char toChar()
Converts the stored value to a char representation and returns the new value.

Returns:
The converted char value. If the stored value is equal to "true", the return value will be 1. If the value could not be converted the return value will be 0. Otherwise, the return value should be a value between Character.MIN_VALUE and Character.MAX_VALUE.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.

toShort

public short toShort()
Converts the stored value to a short representation and returns the new value.

Returns:
The converted short value. If the stored value is equal to "true", the return value will be 1. If the value could not be converted the return value will be 0. Otherwise, the return value should be a value between Short.MIN_VALUE and Short.MAX_VALUE.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.

toInt

public int toInt()
Converts the stored value to a int representation and returns the new value.

Returns:
The converted int value. If the stored value is equal to "true", the return value will be 1. If the value could not be converted the return value will be 0. Otherwise, the return value should be a value between Integer.MIN_VALUE and Integer.MAX_VALUE.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.

toLong

public long toLong()
Converts the stored value to a long representation and returns the new value.

Returns:
The converted long value. If the stored value is equal to "true", the return value will be 1. If the value could not be converted the return value will be 0. Otherwise, the return value should be a value between Long.MIN_VALUE and Long.MAX_VALUE.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.

toFloat

public float toFloat()
Converts the stored value to a float representation and returns the new value.

Returns:
The converted float value. If the stored value is equal to "true", the return value will be 1. If the value could not be converted the return value will be 0. Otherwise, the return value should be a value between Float.MIN_VALUE and Float.MAX_VALUE.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.

toDouble

public double toDouble()
Converts the stored value to a double representation and returns the new value.

Returns:
The converted double value. If the stored value is equal to "true", the return value will be 1. If the value could not be converted the return value will be 0. Otherwise, the return value should be a value between Double.MIN_VALUE and Double.MAX_VALUE.
Throws:
java.lang.ClassCastException - if the stored value could not be converted to a known type.


Copyright © 2008 AMX LLC. All Rights Reserved.