|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.tangosol.util.ClassHelper
public abstract class ClassHelper
This abstract class contains dynamic (reflect-based) class, method, and field manipulation methods.
Note: This class is primarily for supporting generated code.
Field Summary | |
---|---|
static Object[] |
VOID
Useful constant for methods with no arguments. |
static Class[] |
VOID_PARAMS
Useful constant for methods with no parameters. |
Constructor Summary | |
---|---|
ClassHelper()
|
Method Summary | |
---|---|
static Method |
findMethod(Class clz,
String sName,
Class[] aclzParam,
boolean fStatic)
Find a Method that matches the specified name and parameter types. |
static String |
getCompositeName(Class clz,
String sName)
Build the composite name of a class based on an existing class and a second class name. |
static String |
getCompositeName(String sName1,
String sName2)
Build the composite name of a class based on an existing class name and a second class name. |
static String |
getCompositePackage(String pkg1,
String pkg2)
Build the composite name of a package based on two package names. |
static String |
getDerivedName(Class clz,
String sPrefix)
Build the name of a "derived" class based on an existing class and a "derived" class prefix. |
static String |
getDerivedName(String sName,
String sPrefix)
Build the name of a "derived" class based on the name of an existing class and a "derived" class prefix. |
static String |
getPackageName(Class clz)
Determine the package name of a class. |
static String |
getPackageName(String sName)
Determine the package name from a class (or package) name. |
static Resources |
getPackageResources(Class clz)
Load the default package resources for the specified class. |
static Resources |
getPackageResources(String sClass)
Load the default package resources for the specified class name. |
static String |
getQualifiedName(String pkg,
String sName)
Build the fully qualified name of a class based on a package name and a simple class name. |
static Resources |
getResources(Class clz,
String sName)
Load the named resources for the specified class. |
static String |
getSimpleName(Class clz)
Determine the simple (unqualified) name of a class. |
static String |
getSimpleName(String sName)
Determine the simple (unqualified) name of a class. |
static Object |
invoke(Class clz,
Object obj,
String sName,
Object[] aoParam)
Invoke the specified method using the passed arguments. |
static Object |
invoke(Object obj,
String sName,
Object[] aoParam)
Invoke the specified instance method using the passed arguments. |
static Object |
invokeStatic(Class clz,
String sName,
Object[] aoParam)
Invoke the specified static method using the passed arguments. |
static boolean |
isInstanceOf(Object obj,
Class clz)
Determine if the passed object is an instance of the specified class. |
static boolean |
isInstanceOf(Object obj,
String sClz)
Determine if the passed object is an instance of the specified class. |
static boolean |
isPartialNameLegal(String sName)
Determine if a partial name (for example, a prefix, class name, package name, etc. |
static boolean |
isQualifiedNameLegal(String sName)
Determine if the passed string is a legal dot-delimited identifier. |
static boolean |
isSimpleNameLegal(String sName)
Determine if the passed string is a legal simple name. |
static Object |
newInstance(Class clz,
Object[] aoParam)
Instantiate the specified class using the specified parameters. |
Field Detail |
---|
public static final Class[] VOID_PARAMS
public static final Object[] VOID
Constructor Detail |
---|
public ClassHelper()
Method Detail |
---|
public static boolean isInstanceOf(Object obj, String sClz)
obj
- the objectsClz
- the class namepublic static boolean isInstanceOf(Object obj, Class clz)
obj
- the objectclz
- the classpublic static String getPackageName(Class clz)
clz
- the class to determine the package of
public static String getPackageName(String sName)
in out ------- ------- [blank] [blank] a [blank] .a .a. a. a. .a. .a. a.b a. .a.b .a. a.b. a.b. .a.b. .a.b.
sName
- the class name to determine the package of
public static String getSimpleName(Class clz)
clz
- the class to determine the simple name of
public static String getSimpleName(String sName)
in out ------- ------- [blank] [blank] a a .a [blank] a. [blank] .a. [blank] a.b b .a.b b a.b. [blank] .a.b. [blank]
sName
- the simple or qualified name of the class (or package)
public static String getQualifiedName(String pkg, String sName)
pkg
- package namesName
- simple class name
public static String getCompositePackage(String pkg1, String pkg2)
pkg1 pkg2 composite ----------- -------------- ---------------------- [blank] [blank] [blank] [blank] yourpkg. yourpkg. [blank] .yourpkg. .yourpkg. mypkg. [blank] mypkg. .mypkg. [blank] .mypkg. mypkg. yourpkg. yourpkg. mypkg. .yourpkg. mypkg.yourpkg. .mypkg. .yourpkg. .mypkg.yourpkg.
pkg1
- the first (base) packagepkg2
- the second (extending/overriding) package
public static String getCompositeName(Class clz, String sName)
clz
- the existing classsName
- the name to use to build the composite class name
public static String getCompositeName(String sName1, String sName2)
Class Name Derived ----------- -------------- ---------------------- Test Net Net mypkg.Test Net mypkg.Net mypkg.Test yourpkg. yourpkg.Test mypkg.Test .yourpkg mypkg.yourpkg.Test mypkg.Test .yourpkg. mypkg.yourpkg.Test mypkg.Test yourpkg.Net yourpkg.Net mypkg.Test .yourpkg.Net mypkg.yourpkg.Net mypkg.Test .yourpkg.Net. mypkg.yourpkg.Net.Test
sName1
- the existing class namesName2
- the name to use to build the composite class name
public static String getDerivedName(Class clz, String sPrefix)
clz
- the existing classsPrefix
- the prefix to apply to the existing class to determine
the name of the "derived" class
public static String getDerivedName(String sName, String sPrefix)
Class Prefix Derived ----------- ------------- ---------------------- Test Net NetTest mypkg.Test Net mypkg.NetTest mypkg.Test yourpkg. yourpkg.Test mypkg.Test .yourpkg mypkg.yourpkg.Test mypkg.Test .yourpkg. mypkg.yourpkg.Test mypkg.Test yourpkg.Net yourpkg.NetTest mypkg.Test .yourpkg.Net mypkg.yourpkg.NetTest mypkg.Test .yourpkg.Net. mypkg.yourpkg.Net.Test
sName
- the existing class namesPrefix
- the prefix to apply to the existing class to determine
the name of the "derived" class
public static boolean isPartialNameLegal(String sName)
sName
- the partial name
public static boolean isSimpleNameLegal(String sName)
sName
- the string containing the name
public static boolean isQualifiedNameLegal(String sName)
sName
- the string containing the dot-delimited identifier
public static Resources getPackageResources(String sClass) throws MissingResourceException
sClass
- the class name (fully qualified) to get the resources for
MissingResourceException
getResources(java.lang.Class, java.lang.String)
public static Resources getPackageResources(Class clz) throws MissingResourceException
clz
- the class to get the resources for
MissingResourceException
getResources(java.lang.Class, java.lang.String)
public static Resources getResources(Class clz, String sName) throws MissingResourceException
clz
- the class to get the resources forsName
- the name of the resource class
MissingResourceException
public static Object newInstance(Class clz, Object[] aoParam) throws InstantiationException, InvocationTargetException
clz
- the class to instantiateaoParam
- the constructor parameters
InstantiationException
- if an exception is raised trying
to instantiate the object, whether the exception is a
security, method access, no such method, or instantiation
exception
InvocationTargetException
- if the constructor of the new
object instance raises an exceptionpublic static Object invokeStatic(Class clz, String sName, Object[] aoParam) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
clz
- the class to invoke the static method ofsName
- the method nameaoParam
- the method arguments
NoSuchMethodException
IllegalAccessException
InvocationTargetException
public static Object invoke(Object obj, String sName, Object[] aoParam) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
obj
- the object to invoke the instance method ofsName
- the method nameaoParam
- the method arguments
NoSuchMethodException
IllegalAccessException
InvocationTargetException
public static Object invoke(Class clz, Object obj, String sName, Object[] aoParam) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
clz
- the class to invoke the method onobj
- the object to invoke the method onsName
- the method nameaoParam
- the method arguments
NoSuchMethodException
IllegalAccessException
InvocationTargetException
public static Method findMethod(Class clz, String sName, Class[] aclzParam, boolean fStatic)
clz
- the class referencesName
- the method nameaclzParam
- the parameter types (some array elements could be null)fStatic
- the method scope flag
|
CoherenceTM v3.3 Copyright© 2000-2007 by Oracle Corporation |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |