com.mockrunner.util.common
Class ClassUtil

java.lang.Object
  extended by com.mockrunner.util.common.ClassUtil

public class ClassUtil
extends java.lang.Object


Constructor Summary
ClassUtil()
           
 
Method Summary
static java.lang.String getArgumentName(java.lang.Class argumentType)
          Returns a suitable argument name for arguments of type argumentType.
static java.lang.String getClassName(java.lang.Class clazz)
          Returns the name of the specified class.
static java.lang.Class[] getImplementedInterfaces(java.lang.Class clazz)
          Returns all interfaces implemented by the specified class including all interfaces implemented by super classes.
static java.lang.Class[] getInheritanceHierarchy(java.lang.Class clazz)
          Returns the inheritance hierarchy of the specified class.
static java.lang.String getPackageName(java.lang.Class clazz)
          Returns the name of the package of the specified class.
static boolean isKeyword(java.lang.String name)
          Returns if the specified string is a Java language keyword.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtil

public ClassUtil()
Method Detail

getPackageName

public static java.lang.String getPackageName(java.lang.Class clazz)
Returns the name of the package of the specified class. If the class has no package, an empty String will be returned.

Parameters:
clazz - the Class
Returns:
the package name

getClassName

public static java.lang.String getClassName(java.lang.Class clazz)
Returns the name of the specified class. This method only returns the class name without package information. If the specified class represents a primitive type, the name of the primitive type will be returned. If the specified class is an array, [] will be appended to the name (once for each dimension).

Parameters:
clazz - the Class
Returns:
the class name

getImplementedInterfaces

public static java.lang.Class[] getImplementedInterfaces(java.lang.Class clazz)
Returns all interfaces implemented by the specified class including all interfaces implemented by super classes. If the specified class is itself an interfaces or the specified class does not implement any interfaces, this method returns an empty array.

Parameters:
clazz - the Class
Returns:
all interfaces implemented by the specified class

getInheritanceHierarchy

public static java.lang.Class[] getInheritanceHierarchy(java.lang.Class clazz)
Returns the inheritance hierarchy of the specified class. The returned array includes all superclasses of the specified class starting with the most general superclass, which is java.lang.Object. The returned array also includes the class itself as the last element. Implemented interfaces are not included.

Parameters:
clazz - the Class
Returns:
all superclasses, most general superclass first

isKeyword

public static boolean isKeyword(java.lang.String name)
Returns if the specified string is a Java language keyword.

Parameters:
name - the string
Returns:
true if it is a keyword, false otherwise

getArgumentName

public static java.lang.String getArgumentName(java.lang.Class argumentType)
Returns a suitable argument name for arguments of type argumentType. Simply takes the class name and converts the starting characters to lower case (by preserving one upper case character). E.g. the result of JMSTestModule is jmsTestModule. If the specified argumentType is an array, an "s" is appended to the string. If the resulting string is a Java keyword, "Value" is appended to the string (which is always the case with primitive types).

Parameters:
argumentType - the argument type
Returns:
a suitable mixed case argument name