com.glaivestone.javax.lang
Class ClassX

java.lang.Object
  |
  +--com.glaivestone.javax.lang.ClassX

public class ClassX
extends java.lang.Object

General-purpose extensions to the standard Class services.

Provides general-purpose convenience services to support common usage patterns for Java reflection

Author:
Deb Lewis
, Gary Gregory

Field Summary
static java.util.List PRIMITIVE_TYPE_NAMES
          List containing the names of the Java primitive types
 
Method Summary
static java.lang.Class classForNameOrNull(java.lang.String className)
          Answer the Class identified by the fully qualified class name.
static java.lang.reflect.Method getMethodOrNull(java.lang.Class aClass, java.lang.String messageName, java.lang.Class[] parmTypes)
          Answer the public method supported by the specified class with the given name and parameter type signature.
static java.lang.String getPackageName(java.lang.Class aClass)
          Answer the package name of the class.
static java.lang.String getPackageName(java.lang.String fullyQualifiedName)
          Answer the package name of a fully qualified class name.
static java.lang.String getSimpleName(java.lang.Class aClass)
          Answer the simple (unqualified) name of the class.
static java.lang.String getSimpleName(java.lang.String fullyQualifiedName)
          Answer the simple (unqualified) name of the class from its fully qualified class name.
static boolean isPrimitiveType(java.lang.String typeName)
          Answer whether a type name refers to a primitive type.
static boolean isProperSubclass(java.lang.Class aClass, java.lang.Class baseClass)
          Answer whether a class is a proper subclass of a specified base class.
static java.lang.Object newInstanceOrNull(java.lang.Class aClass)
          Create and return a new instance of the specified Class Return null if an instance cannot be created.
static java.lang.Object newInstanceOrNull(java.lang.String className)
          Create and return a new instance of the class identified by the fully qualified class name.
static java.lang.String toSignatureDescription(java.lang.reflect.Method aMethod)
          Answer a description of the message signature of a method.
static java.lang.String toSignatureDescription(java.lang.String messageName, java.lang.Class[] parmTypes, java.lang.Class returnType)
          Answer a description of the signature of a message with the given parameter and return types.
static java.lang.String toSimpleSignatureDescription(java.lang.reflect.Method aMethod)
          Answer a description of the message signature of a method.
static java.lang.String toSimpleSignatureDescription(java.lang.String messageName, java.lang.Class[] parmTypes, java.lang.Class returnType)
          Answer a description of the signature of a message with the given parameter and return types.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMITIVE_TYPE_NAMES

public static final java.util.List PRIMITIVE_TYPE_NAMES
List containing the names of the Java primitive types

Method Detail

classForNameOrNull

public static java.lang.Class classForNameOrNull(java.lang.String className)
Answer the Class identified by the fully qualified class name. Returns null if the class does not exist or cannot be loaded.

Exceptions raised by the standard Class.forName operation are suppressed; Use this convenience operation when you just know it's gonna work or if you don't care why not if it doesn't.

See Also:
Class.forName(String)

getMethodOrNull

public static java.lang.reflect.Method getMethodOrNull(java.lang.Class aClass,
                                                       java.lang.String messageName,
                                                       java.lang.Class[] parmTypes)
Answer the public method supported by the specified class with the given name and parameter type signature. Returns if no such method is found in the class or a superclass.

The parameter types array can be null for for no-argument message.

Exceptions raised by the standard getMethod operation are suppressed; Use this convenience operation when you just know it's gonna work or if you don't care why not if it doesn't.

See Also:
Class.getMethod(String, Class[])

getPackageName

public static java.lang.String getPackageName(java.lang.Class aClass)
Answer the package name of the class. Returns null if the class is unpackaged.


getPackageName

public static java.lang.String getPackageName(java.lang.String fullyQualifiedName)
Answer the package name of a fully qualified class name. Returns null if the class name is unqualified.


getSimpleName

public static java.lang.String getSimpleName(java.lang.Class aClass)
Answer the simple (unqualified) name of the class.


getSimpleName

public static java.lang.String getSimpleName(java.lang.String fullyQualifiedName)
Answer the simple (unqualified) name of the class from its fully qualified class name.


isPrimitiveType

public static boolean isPrimitiveType(java.lang.String typeName)
Answer whether a type name refers to a primitive type.

Parameters:
typeName - the type name to test
Returns:
a boolean indicating whether typeName is the name of a primitive type

isProperSubclass

public static boolean isProperSubclass(java.lang.Class aClass,
                                       java.lang.Class baseClass)
Answer whether a class is a proper subclass of a specified base class.

This is a predicate for working with (concrete) classes and is not the same as testing for sub-type relationships, such as might be done with interfaces rather than actual backing classes.

Parameters:
aClass - the Class to be checked
baseClass - the base Class
Returns:
a boolean indicating whether aClass is a proper subclass of baseClass

newInstanceOrNull

public static java.lang.Object newInstanceOrNull(java.lang.String className)
Create and return a new instance of the class identified by the fully qualified class name. Return null if an instance cannot be created.

Exceptions raised by the standard Class.newInstance operation are suppressed; Use this convenience operation when you just know in your heart that it's gonna work or if you just don't care why not if it doesn't.

See Also:
newInstanceOrNull(java.lang.Class)

newInstanceOrNull

public static java.lang.Object newInstanceOrNull(java.lang.Class aClass)
Create and return a new instance of the specified Class Return null if an instance cannot be created.

Exceptions raised by the standard newInstance operation are suppressed; Use this convenience operation when you just know in your heart that it's gonna work or if you just don't care why not if it doesn't. *

See Also:
Class.newInstance()

toSignatureDescription

public static java.lang.String toSignatureDescription(java.lang.reflect.Method aMethod)
Answer a description of the message signature of a method. Fully qualified type names are used for the parameter and return types.


toSignatureDescription

public static java.lang.String toSignatureDescription(java.lang.String messageName,
                                                      java.lang.Class[] parmTypes,
                                                      java.lang.Class returnType)
Answer a description of the signature of a message with the given parameter and return types. using fully qualified type names.


toSimpleSignatureDescription

public static java.lang.String toSimpleSignatureDescription(java.lang.reflect.Method aMethod)
Answer a description of the message signature of a method. Simple (unqualified) type names are used for the parameter and return types.


toSimpleSignatureDescription

public static java.lang.String toSimpleSignatureDescription(java.lang.String messageName,
                                                            java.lang.Class[] parmTypes,
                                                            java.lang.Class returnType)
Answer a description of the signature of a message with the given parameter and return types. Simple (unqualified) type names are used for the parameter and return types.


GFL 1.1 API