org.enhydra.zeus.util
Class ClassUtils

java.lang.Object
  |
  +--org.enhydra.zeus.util.ClassUtils

public class ClassUtils
extends java.lang.Object

ClassUtils is a Zeus utility class that provides methods that deal with the various classes and types that may be used in data binding. Specifically, this will deal with the String Java types that Generators deal with, and relate them to Java Class objects.

Author:
Brett McLaughlin

Field Summary
static int COLLECTION_TYPE_ARRAY
          Constant for using Array as the default collection type
static int COLLECTION_TYPE_LIST
          Constant for using List as the default collection type
 
Constructor Summary
ClassUtils()
           
 
Method Summary
static java.lang.String getCollectionImplClass(java.lang.String collectionClass)
           For a supplied Collection class, this will return an implementation of that class.
static int getCollectionTypeAsInt(java.lang.String collectionTypeString)
           This will convert a String representation of a supplied collection type, and convert it to one of the int constants specified in this class.
static java.lang.String getCollectionTypeAsString(int collectionType)
           This returns the currently selected default collection type, as a String that maps to a Java class.
static java.lang.Object getParameter(java.lang.String value, java.lang.Class paramType)
           This will take the String value supplied and convert it to an Object of the type specified in paramType.
static boolean isCollectionClass(java.lang.String javaType)
           This will determine if the supplied Java type (in String form) is one of the Java Collection classes.
static boolean isCollectionConstant(int collectionType)
           This checks to see if the supplied int constant is a legal collection type, as defined in this class.
static boolean isJavaPrimitive(java.lang.String javaType)
           This will indicate whether the supplied Java type is a Java primitive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLLECTION_TYPE_LIST

public static final int COLLECTION_TYPE_LIST
Constant for using List as the default collection type

COLLECTION_TYPE_ARRAY

public static final int COLLECTION_TYPE_ARRAY
Constant for using Array as the default collection type
Constructor Detail

ClassUtils

public ClassUtils()
Method Detail

isJavaPrimitive

public static boolean isJavaPrimitive(java.lang.String javaType)

This will indicate whether the supplied Java type is a Java primitive.

Parameters:
javaType - the Java type to check against Java primitives
Returns:
boolean whether the supplied type is a Java primitive

isCollectionClass

public static boolean isCollectionClass(java.lang.String javaType)

This will determine if the supplied Java type (in String form) is one of the Java Collection classes. The type supplied must be a fully-qualified class name, like java.util.List.

Parameters:
javaType - the String name of the Java type to check for.
Returns:
boolean - whether the class is a Java Collection.

getCollectionImplClass

public static java.lang.String getCollectionImplClass(java.lang.String collectionClass)

For a supplied Collection class, this will return an implementation of that class. For example, specifying java.util.List to this method would return java.util.LinkedList, which is a concrete class. If the supplied class is already a concrete class, it is returned unchanged.

Parameters:
collectionClass - String name of collection class/interface
Returns:
String - fully qualified concrete class to use.

isCollectionConstant

public static boolean isCollectionConstant(int collectionType)

This checks to see if the supplied int constant is a legal collection type, as defined in this class.

Parameters:
collectionType - int to check against constants.
Returns:
boolean - whether the supplied type is a legal collection type constant.

getCollectionTypeAsInt

public static int getCollectionTypeAsInt(java.lang.String collectionTypeString)
                                  throws InvalidCollectionTypeException

This will convert a String representation of a supplied collection type, and convert it to one of the int constants specified in this class.

Parameters:
collectionTypeString - the collection type to convert to a constant.
Returns:
int - the constant representation of the type.
Throws:
InvalidCollectionTypeException - - when an illegal collection type is supplied.
See Also:
{@link #COLLECTION_TYPE_LIST}, {@link #COLLECTION_TYPE_ARRAY}

getCollectionTypeAsString

public static java.lang.String getCollectionTypeAsString(int collectionType)

This returns the currently selected default collection type, as a String that maps to a Java class. For example, if the default collection type is currently "List", this would return the value "java.util.List". The class name returned here is always a fully qualified class name.

Returns:
String - the default collection type as a Java class name.

getParameter

public static java.lang.Object getParameter(java.lang.String value,
                                            java.lang.Class paramType)

This will take the String value supplied and convert it to an Object of the type specified in paramType.

Parameters:
value - String value to convert.
paramType - Class with type to convert to.
Returns:
Object - value in correct type.


Copyright © 2001 Enhydra. All Rights Reserved.