net.sourceforge.pmd.util
Class ClassUtil

java.lang.Object
  extended by net.sourceforge.pmd.util.ClassUtil

public final class ClassUtil
extends java.lang.Object

Various class-related utility methods intended for mapping common java.lang types to their short short forms allowing end users to enter these names in UIs without the package prefixes.

Author:
Brian Remedios

Field Summary
static java.lang.Class<?>[] EMPTY_CLASS_ARRAY
           
 
Method Summary
static java.util.Map<java.lang.String,java.util.List<java.lang.reflect.Method>> asMethodGroupsByTypeName(java.lang.reflect.Method[] methods)
          Return the methods as a map keyed by their common declaration types.
static java.lang.String asShortestName(java.lang.Class<?> type)
          Return the name of the type in its short form if its known to us otherwise return its name fully packaged.
static java.util.Map<java.lang.Class<?>,java.lang.String> getClassShortNames()
           
static java.lang.Class<?> getPrimitiveTypeFor(java.lang.String name)
          Returns the type(class) for the name specified or null if not found.
static java.lang.Class<?> getTypeFor(java.lang.String shortName)
          Attempt to determine the actual class given the short name.
static java.lang.reflect.Method methodFor(java.lang.Class<?> clasz, java.lang.String methodName, java.lang.Class<?>[] paramTypes)
          Attempts to return the specified method from the class provided but will walk up its superclasses until it finds a match.
static java.lang.String withoutPackageName(java.lang.String fullTypeName)
          Returns the abbreviated name of the type, without the package name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CLASS_ARRAY

public static final java.lang.Class<?>[] EMPTY_CLASS_ARRAY
Method Detail

getPrimitiveTypeFor

public static java.lang.Class<?> getPrimitiveTypeFor(java.lang.String name)
Returns the type(class) for the name specified or null if not found.

Parameters:
name - String
Returns:
Class

getClassShortNames

public static java.util.Map<java.lang.Class<?>,java.lang.String> getClassShortNames()

getTypeFor

public static java.lang.Class<?> getTypeFor(java.lang.String shortName)
Attempt to determine the actual class given the short name.

Parameters:
shortName - String
Returns:
Class

asShortestName

public static java.lang.String asShortestName(java.lang.Class<?> type)
Return the name of the type in its short form if its known to us otherwise return its name fully packaged.

Parameters:
type -
Returns:
String

withoutPackageName

public static java.lang.String withoutPackageName(java.lang.String fullTypeName)
Returns the abbreviated name of the type, without the package name

Parameters:
fullTypeName -
Returns:
String

methodFor

public static java.lang.reflect.Method methodFor(java.lang.Class<?> clasz,
                                                 java.lang.String methodName,
                                                 java.lang.Class<?>[] paramTypes)
Attempts to return the specified method from the class provided but will walk up its superclasses until it finds a match. Returns null if it doesn't.

Parameters:
clasz - Class
methodName - String
paramTypes - Class[]
Returns:
Method

asMethodGroupsByTypeName

public static java.util.Map<java.lang.String,java.util.List<java.lang.reflect.Method>> asMethodGroupsByTypeName(java.lang.reflect.Method[] methods)
Return the methods as a map keyed by their common declaration types.

Parameters:
methods -
Returns:
Map>


Copyright © 2002-2015 InfoEther. All Rights Reserved.