Class JavaTypeHelper
- java.lang.Object
-
- com.sun.jdo.spi.persistence.utility.JavaTypeHelper
-
- Direct Known Subclasses:
JavaClassWriterHelper
public class JavaTypeHelper extends Object
This is a helper class which provides some basic java type convenience methods: extraction of a package from a fully qualified class name, extraction of a short (non-qualified) name from a fully qualified class name, and various wrapper and primitive type methods.- Author:
- Rochelle Raccah
-
-
Constructor Summary
Constructors Constructor Description JavaTypeHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getPackageName(String className)
Returns the package portion of the specified classstatic Class
getPrimitiveClass(String primitiveName)
Returns the primitive class associated with the supplied primitive type name.static String
getPrimitiveName(Class wrapper)
Returns the name of the primitive type associated with the supplied wrapper class.static String
getShortClassName(String className)
Returns the name of a class without the package name.static Class
getWrapperClass(Class primitive)
Returns the wrapper class associated with the supplied primitive class.static String
getWrapperName(String primitiveName)
Returns the name of the wrapper class associated with the supplied primitive type name.static Boolean
valueOf(boolean flag)
Returns the Boolean wrapper object for true or false corresponding to the supplied argument.
-
-
-
Method Detail
-
getPackageName
public static String getPackageName(String className)
Returns the package portion of the specified class- Parameters:
className
- the name of the class from which to extract the package- Returns:
- package portion of the specified class
-
getShortClassName
public static String getShortClassName(String className)
Returns the name of a class without the package name. For example: if input = "java.lang.Object" , then output = "Object".- Parameters:
className
- fully qualified classname
-
getWrapperClass
public static Class getWrapperClass(Class primitive)
Returns the wrapper class associated with the supplied primitive class.- Parameters:
primitive
- the primitive class to be used for lookup.- Returns:
- the associated wrapper class.
-
getPrimitiveClass
public static Class getPrimitiveClass(String primitiveName)
Returns the primitive class associated with the supplied primitive type name.- Parameters:
primitiveName
- the name of the primitive to be used for lookup.- Returns:
- the associated primitive class.
-
getWrapperName
public static String getWrapperName(String primitiveName)
Returns the name of the wrapper class associated with the supplied primitive type name.- Parameters:
primitiveName
- the name of the primitive to be used for lookup.- Returns:
- the associated wrapper class name.
-
getPrimitiveName
public static String getPrimitiveName(Class wrapper)
Returns the name of the primitive type associated with the supplied wrapper class.- Parameters:
wrapper
- the wrapper class to be used for lookup.- Returns:
- the associated primitive type name.
-
valueOf
public static Boolean valueOf(boolean flag)
Returns the Boolean wrapper object for true or false corresponding to the supplied argument. This is to provide a convenience method for this conversion but to prevent calling the Boolean constructor which has been determined to be unnecessary and a performance problem. JDK 1.4 provides such a method, but some of our code still works with JDK 1.3.- Parameters:
flag
- the primitive boolean object to be translated to a Boolean wrapper.- Returns:
- the associated true/false shared wrapper object
-
-