nl.tudelft.simulation.language.primitives
Class Primitive

java.lang.Object
  extended by nl.tudelft.simulation.language.primitives.Primitive

public final class Primitive
extends Object

The Primitive class is a utility class to deal with primitives. Besides widening and unwidening this class casts and parses UTF8 strings into appropriate primitive classes.

(c) copyright 2002-2005 Delft University of Technology , the Netherlands.

See for project information www.simulation.tudelft.nl/language
License of use: Lesser General Public License (LGPL) , no warranty

Version:
$Revision: 1.1 $ $Date: 2007/01/06 13:25:55 $
Author:
Peter Jacobs

Method Summary
static Object[] cast(Class[] classes, Object[] values)
          casts a set of values to classes
static Object cast(Class clazz, Object object)
          casts an object to a instance of clazz
static Class forName(String className)
          returns the primitiveClass of the name given as defined by the Java VM class constants.
static Class getPrimitive(Class wrapperClass)
          gets the primitive of the given wrapperClass
static Class getWrapper(Class primitiveClass)
          gets the wrapper of this primitive class
static Boolean toBoolean(Object object)
          casts an object to Boolean
static Byte toByte(Object object)
          casts an object to Byte
static Character toCharacter(Object object)
          casts an object to Character
static Double toDouble(Object object)
          casts an object to Double
static Float toFloat(Object object)
          casts an object to Float
static Integer toInteger(Object object)
          casts an object to Integer
static Long toLong(Object object)
          casts an object to Long
static Short toShort(Object object)
          casts an object to Short
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cast

public static Object[] cast(Class[] classes,
                            Object[] values)
casts a set of values to classes

Parameters:
classes - the classes to cast to
values - the values
Returns:
the newly creates values

cast

public static Object cast(Class clazz,
                          Object object)
casts an object to a instance of clazz

Parameters:
clazz - the class to cast to
object - the object to cast
Returns:
the casted object

forName

public static Class forName(String className)
returns the primitiveClass of the name given as defined by the Java VM class constants. (i.e. both "int" and "I" return int.class). Both void and "V" return void.class. null is returned whenever an unknown className is given.

Parameters:
className - the className
Returns:
Class the primitiveClass

getPrimitive

public static Class getPrimitive(Class wrapperClass)
gets the primitive of the given wrapperClass

Parameters:
wrapperClass - the wrapper class
Returns:
the primitive Class. null is returned whenever wrapperClass is not a wrapperclass.

getWrapper

public static Class getWrapper(Class primitiveClass)
gets the wrapper of this primitive class

Parameters:
primitiveClass - the primitive class
Returns:
the Class. null is returned whenever wrapperClass is not a wrapperclass.

toBoolean

public static Boolean toBoolean(Object object)
casts an object to Boolean

Parameters:
object - the object
Returns:
Boolean

toByte

public static Byte toByte(Object object)
casts an object to Byte

Parameters:
object - the object
Returns:
Byte

toCharacter

public static Character toCharacter(Object object)
casts an object to Character

Parameters:
object - the object to parse
Returns:
Integer the result

toDouble

public static Double toDouble(Object object)
casts an object to Double

Parameters:
object - the object to parse
Returns:
Integer the result

toFloat

public static Float toFloat(Object object)
casts an object to Float

Parameters:
object - the object to parse
Returns:
Float the result

toLong

public static Long toLong(Object object)
casts an object to Long

Parameters:
object - the object to parse
Returns:
Long the result

toShort

public static Short toShort(Object object)
casts an object to Short

Parameters:
object - the object to parse
Returns:
Long the result

toInteger

public static Integer toInteger(Object object)
casts an object to Integer

Parameters:
object - the object to parse
Returns:
Integer the result


Copyright © 2002-2011 Delft University of Technology, the Netherlands. All Rights Reserved.