ewe.reflect
Class Wrapper

java.lang.Object
  extended byewe.reflect.Wrapper
All Implemented Interfaces:
DataConverter, Stringable

public class Wrapper
extends Object
implements DataConverter, Stringable


Field Summary
static int ARRAY
           
static int BOOLEAN
           
static int BYTE
           
static int CHAR
           
static int DOUBLE
           
protected  double doubleValue
           
static int FLOAT
           
protected  float floatValue
           
static int INT
           
static int LONG
           
protected  long longValue
           
static Wrapper[] noParameter
           
static int OBJECT
           
protected static String objectClass
           
protected  Object objValue
           
protected  int refValue
           
static int SHORT
           
protected static String stringClass
           
protected  int type
           
protected  int value
           
protected static String valueClass
           
static int VMREFERENCE
           
static int VOID
           
 
Constructor Summary
Wrapper()
           
 
Method Summary
 boolean convertData(Wrapper source, String sourceType, Wrapper dest, String destType)
          Return true if the conversion was successfull.
 void copyValue(Wrapper from)
           
static boolean doConvertData(Wrapper source, String sourceType, Wrapper dest, String destType)
           
 void fromJavaWrapper(Object ret)
          Set the value of this Wrapper to be equal to a standard Java wrapper Object (e.g.
 void fromString(String what)
           
 Object getArray()
           
 boolean getBoolean()
           
 byte getByte()
           
 char getChar()
           
 Wrapper getCopy()
           
 double getDouble()
           
 float getFloat()
           
 int getInt()
           
 long getLong()
           
 Object getObject()
           
 short getShort()
           
 int getType()
           
 boolean isCompatibleWith(int aType)
           
 Wrapper setArray(Object v)
           
 Wrapper setBoolean(boolean v)
           
 Wrapper setByte(byte v)
           
 Wrapper setChar(char v)
           
 Wrapper setDouble(double d)
           
 Wrapper setFloat(float v)
           
 Wrapper setInt(int v)
           
 Wrapper setLong(long v)
           
 Wrapper setObject(Object v)
           
 Wrapper setShort(short v)
           
protected  Wrapper setType(int type)
           
 boolean toBoolean()
           
 byte toByte()
           
 char toChar()
           
 double toDouble()
           
static Wrapper[] toEweWrappers(Object[] javaWrappers)
          Convert an array of standard Java wrapper objects to an array of Ewe Wrappers.
 float toFloat()
           
 int toInt()
           
 Object toJavaWrapper()
          Convert this Wrapper to a standard Java wrapper Object (e.g.
static Object[] toJavaWrappers(Wrapper[] wrappers)
          Convert an array of Ewe Wrappers to an array of standard Java wrapper Objects.
 long toLong()
           
 short toShort()
           
 String toString()
          Return a String representation of this object.
static Object widenJavaWrapper(Object value, Class type)
          Widen a Java wrapper object to a specified primitive type.
 void zero()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Field Detail

type

protected int type

value

protected int value

floatValue

protected float floatValue

objValue

protected Object objValue

refValue

protected int refValue

longValue

protected long longValue

doubleValue

protected double doubleValue

VOID

public static final int VOID
See Also:
Constant Field Values

BYTE

public static final int BYTE
See Also:
Constant Field Values

CHAR

public static final int CHAR
See Also:
Constant Field Values

SHORT

public static final int SHORT
See Also:
Constant Field Values

INT

public static final int INT
See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

LONG

public static final int LONG
See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

OBJECT

public static final int OBJECT
See Also:
Constant Field Values

ARRAY

public static final int ARRAY
See Also:
Constant Field Values

VMREFERENCE

public static final int VMREFERENCE
See Also:
Constant Field Values

stringClass

protected static final String stringClass
See Also:
Constant Field Values

objectClass

protected static final String objectClass
See Also:
Constant Field Values

valueClass

protected static final String valueClass
See Also:
Constant Field Values

noParameter

public static Wrapper[] noParameter
Constructor Detail

Wrapper

public Wrapper()
Method Detail

setType

protected Wrapper setType(int type)

setLong

public Wrapper setLong(long v)

setDouble

public Wrapper setDouble(double d)

setByte

public Wrapper setByte(byte v)

setChar

public Wrapper setChar(char v)

setShort

public Wrapper setShort(short v)

setInt

public Wrapper setInt(int v)

setBoolean

public Wrapper setBoolean(boolean v)

setFloat

public Wrapper setFloat(float v)

setObject

public Wrapper setObject(Object v)

setArray

public Wrapper setArray(Object v)

getCopy

public Wrapper getCopy()

getType

public int getType()

getInt

public int getInt()

getShort

public short getShort()

getChar

public char getChar()

getByte

public byte getByte()

getBoolean

public boolean getBoolean()

getFloat

public float getFloat()

getObject

public Object getObject()

getArray

public Object getArray()

getLong

public long getLong()

getDouble

public double getDouble()

toByte

public byte toByte()

toShort

public short toShort()

toInt

public int toInt()

toLong

public long toLong()

toChar

public char toChar()

toFloat

public float toFloat()

toDouble

public double toDouble()

toBoolean

public boolean toBoolean()

copyValue

public void copyValue(Wrapper from)

zero

public void zero()

doConvertData

public static boolean doConvertData(Wrapper source,
                                    String sourceType,
                                    Wrapper dest,
                                    String destType)

convertData

public boolean convertData(Wrapper source,
                           String sourceType,
                           Wrapper dest,
                           String destType)
Description copied from interface: DataConverter
Return true if the conversion was successfull.

Specified by:
convertData in interface DataConverter

toString

public String toString()
Description copied from class: Object
Return a String representation of this object.

Specified by:
toString in interface Stringable
Overrides:
toString in class Object
Returns:
a String representing this object.

fromString

public void fromString(String what)
Specified by:
fromString in interface Stringable

isCompatibleWith

public boolean isCompatibleWith(int aType)

toJavaWrapper

public Object toJavaWrapper()
Convert this Wrapper to a standard Java wrapper Object (e.g. java.lang.Integer, java.lang.Boolean)


fromJavaWrapper

public void fromJavaWrapper(Object ret)
Set the value of this Wrapper to be equal to a standard Java wrapper Object (e.g. java.lang.Integer, java.lang.Boolean)


toJavaWrappers

public static Object[] toJavaWrappers(Wrapper[] wrappers)
Convert an array of Ewe Wrappers to an array of standard Java wrapper Objects.

Parameters:
wrappers - the array of Ewe Wrappers.
Returns:
an array of Java wrapper objects.

toEweWrappers

public static Wrapper[] toEweWrappers(Object[] javaWrappers)
Convert an array of standard Java wrapper objects to an array of Ewe Wrappers.

Parameters:
javaWrappers - the array of Java wrapper objects.
Returns:
an array of Ewe Wrappers.

widenJavaWrapper

public static Object widenJavaWrapper(Object value,
                                      Class type)
                               throws IllegalArgumentException
Widen a Java wrapper object to a specified primitive type. For example a Short wrapper will be widened to an Integer if the type class represents the primitive int type.

Parameters:
value - The Java wrapper object to widen.
type - the target primitive Java type.
Returns:
possibly a new Java wrapper object with the same value.
Throws:
IllegalArgumentException - if the value is incompatible with the type.