com.dotmarketing.viewtools.util
Class ClassUtils

java.lang.Object
  extended by com.dotmarketing.viewtools.util.ClassUtils

public class ClassUtils
extends java.lang.Object

Repository for common class and reflection methods.

Version:
$Id: ClassUtils.java 511959 2007-02-26 19:24:39Z nbubna $
Author:
Nathan Bubna

Field Summary
static ClassUtils INSTANCE
           
 
Method Summary
static java.lang.reflect.Method findDeclaredMethod(java.lang.Class clazz, java.lang.String name, java.lang.Class[] params)
           
static java.lang.reflect.Method findMethod(java.lang.Class clazz, java.lang.String name, java.lang.Class[] params)
           
static java.lang.Class getClass(java.lang.String name)
          Load a class with a given name.
static java.lang.Object getFieldValue(java.lang.Class clazz, java.lang.String fieldname)
           
static java.lang.Object getFieldValue(java.lang.String fieldPath)
           
 ClassUtils getInstance()
           
static java.lang.Object getInstance(java.lang.String classname)
           
static java.util.Iterator getIterator(java.lang.Object obj)
          Retrieves an Iterator from or creates and Iterator for the specified object.
static java.net.URL getResource(java.lang.String name, java.lang.Object caller)
          Load a given resource.
static java.io.InputStream getResourceAsStream(java.lang.String name, java.lang.Object caller)
          This is a convenience method to load a resource as a stream.
static java.util.List<java.net.URL> getResources(java.lang.String name, java.lang.Object caller)
          Load all resources with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final ClassUtils INSTANCE
Method Detail

getInstance

public ClassUtils getInstance()

getClass

public static java.lang.Class getClass(java.lang.String name)
                                throws java.lang.ClassNotFoundException
Load a class with a given name.

It will try to load the class in the following order:

Parameters:
name - Fully qualified class name to be loaded
Returns:
Class object
Throws:
java.lang.ClassNotFoundException - if the class cannot be found

getInstance

public static java.lang.Object getInstance(java.lang.String classname)
                                    throws java.lang.ClassNotFoundException,
                                           java.lang.IllegalAccessException,
                                           java.lang.InstantiationException
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException

getResources

public static java.util.List<java.net.URL> getResources(java.lang.String name,
                                                        java.lang.Object caller)
Load all resources with the specified name. If none are found, we prepend the name with '/' and try again. This will attempt to load the resources from the following methods (in order):

Parameters:
name - The name of the resources to load
caller - The instance or Class calling this method

getResource

public static java.net.URL getResource(java.lang.String name,
                                       java.lang.Object caller)
Load a given resource.

This method will try to load the resource using the following methods (in order):

Parameters:
name - The name of the resource to load
caller - The instance or Class calling this method

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String name,
                                                      java.lang.Object caller)
This is a convenience method to load a resource as a stream.

The algorithm used to find the resource is given in getResource()

Parameters:
name - The name of the resource to load
caller - The instance or Class calling this method

findMethod

public static java.lang.reflect.Method findMethod(java.lang.Class clazz,
                                                  java.lang.String name,
                                                  java.lang.Class[] params)
                                           throws java.lang.SecurityException
Throws:
java.lang.SecurityException

findDeclaredMethod

public static java.lang.reflect.Method findDeclaredMethod(java.lang.Class clazz,
                                                          java.lang.String name,
                                                          java.lang.Class[] params)
                                                   throws java.lang.SecurityException
Throws:
java.lang.SecurityException

getFieldValue

public static java.lang.Object getFieldValue(java.lang.String fieldPath)
                                      throws java.lang.ClassNotFoundException,
                                             java.lang.NoSuchFieldException,
                                             java.lang.SecurityException,
                                             java.lang.IllegalAccessException
Throws:
java.lang.ClassNotFoundException
java.lang.NoSuchFieldException
java.lang.SecurityException
java.lang.IllegalAccessException

getFieldValue

public static java.lang.Object getFieldValue(java.lang.Class clazz,
                                             java.lang.String fieldname)
                                      throws java.lang.NoSuchFieldException,
                                             java.lang.SecurityException,
                                             java.lang.IllegalAccessException
Throws:
java.lang.NoSuchFieldException
java.lang.SecurityException
java.lang.IllegalAccessException

getIterator

public static java.util.Iterator getIterator(java.lang.Object obj)
                                      throws java.lang.NoSuchMethodException,
                                             java.lang.IllegalAccessException,
                                             java.lang.reflect.InvocationTargetException
Retrieves an Iterator from or creates and Iterator for the specified object. This method is almost entirely copied from Engine's UberspectImpl class.

Throws:
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException


Copyright © 2013 dotCMS Inc. All Rights Reserved.