Package org.djunits.util
Class Primitive
java.lang.Object
org.djunits.util.Primitive
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.
Copyright (c) 2002-2009 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved.
See for project information www.getSI()mulation.tudelft.nl.
The DSOL project is distributed under the following BSD-style license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Delft University of Technology, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
- Version:
- $Revision: 1.2 $ $Date: 2009/10/21 07:32:43 $
- Author:
- Peter Jacobs
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]
casts a set of values to classes.static Object
casts an object to a instance of clazz.static Class<?>
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
casts an object to Boolean.static Byte
casts an object to Byte.static Character
toCharacter
(Object object) casts an object to Character.static Double
casts an object to Double.static Float
casts an object to Float.static Integer
casts an object to Integer.static Long
casts an object to Long.static Short
casts an object to Short.
-
Method Details
-
cast
casts a set of values to classes.- Parameters:
classes
- the classes to cast tovalues
- the values- Returns:
- the newly creates values
-
cast
casts an object to a instance of clazz.- Parameters:
clazz
- the class to cast toobject
- the object to cast- Returns:
- the casted object
-
forName
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
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
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
casts an object to Boolean.- Parameters:
object
- the object- Returns:
- Boolean
-
toByte
casts an object to Byte.- Parameters:
object
- the object- Returns:
- Byte
-
toCharacter
casts an object to Character.- Parameters:
object
- the object to parse- Returns:
- Integer the result
-
toDouble
casts an object to Double.- Parameters:
object
- the object to parse- Returns:
- Integer the result
-
toFloat
casts an object to Float.- Parameters:
object
- the object to parse- Returns:
- Float the result
-
toLong
casts an object to Long.- Parameters:
object
- the object to parse- Returns:
- Long the result
-
toShort
casts an object to Short.- Parameters:
object
- the object to parse- Returns:
- Long the result
-
toInteger
casts an object to Integer.- Parameters:
object
- the object to parse- Returns:
- Integer the result
-