com.sun.jdo.spi.persistence.utility
Class JavaTypeHelper

java.lang.Object
  extended by com.sun.jdo.spi.persistence.utility.JavaTypeHelper
Direct Known Subclasses:
JavaClassWriterHelper

public class JavaTypeHelper
extends java.lang.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
JavaTypeHelper()
           
 
Method Summary
static java.lang.String getPackageName(java.lang.String className)
          Returns the package portion of the specified class
static java.lang.Class getPrimitiveClass(java.lang.String primitiveName)
          Returns the primitive class associated with the supplied primitive type name.
static java.lang.String getPrimitiveName(java.lang.Class wrapper)
          Returns the name of the primitive type associated with the supplied wrapper class.
static java.lang.String getShortClassName(java.lang.String className)
          Returns the name of a class without the package name.
static java.lang.Class getWrapperClass(java.lang.Class primitive)
          Returns the wrapper class associated with the supplied primitive class.
static java.lang.String getWrapperName(java.lang.String primitiveName)
          Returns the name of the wrapper class associated with the supplied primitive type name.
static java.lang.Boolean valueOf(boolean flag)
          Returns the Boolean wrapper object for true or false corresponding to the supplied argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaTypeHelper

public JavaTypeHelper()
Method Detail

getPackageName

public static java.lang.String getPackageName(java.lang.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 java.lang.String getShortClassName(java.lang.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 java.lang.Class getWrapperClass(java.lang.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 java.lang.Class getPrimitiveClass(java.lang.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 java.lang.String getWrapperName(java.lang.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 java.lang.String getPrimitiveName(java.lang.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 java.lang.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


Copyright © 2012 GlassFish Community. All Rights Reserved.