| java.lang.Object org.jfree.util.ObjectUtilities
ObjectUtilities | final public class ObjectUtilities (Code) | | A collection of useful static utility methods for handling classes and object
instantiation.
author: Thomas Morgner |
Field Summary | |
final public static String | CLASS_CONTEXT A constant for using the ClassContext as source for the classloader. | final public static String | THREAD_CONTEXT A constant for using the TheadContext as source for the classloader. |
Method Summary | |
public static Object | clone(Object object) Returns a clone of the specified object, if it can be cloned, otherwise
throws a CloneNotSupportedException.
Parameters: object - the object to clone (null not permitted). | public static Collection | deepClone(Collection collection) Returns a new collection containing clones of all the items in the
specified collection.
Parameters: collection - the collection (null not permitted). | public static boolean | equal(Object o1, Object o2) Returns true if the two objects are equal OR both
null .
Parameters: o1 - object 1 (null permitted). Parameters: o2 - object 2 (null permitted). | public static ClassLoader | getClassLoader() Returns the custom classloader or null, if no custom classloader is defined. | public static synchronized ClassLoader | getClassLoader(Class c) Returns the classloader, which was responsible for loading the given
class.
Parameters: c - the classloader, either an application class loader or theboot loader. | public static String | getClassLoaderSource() Returns the internal configuration entry, whether the classloader of
the thread context or the context classloader should be used. | public static URL | getResource(String name, Class c) Returns the resource specified by the absolute name. | public static InputStream | getResourceAsStream(String name, Class context) Returns the inputstream for the resource specified by the
absolute name. | public static URL | getResourceRelative(String name, Class c) Returns the resource specified by the relative name. | public static InputStream | getResourceRelativeAsStream(String name, Class context) Returns the inputstream for the resource specified by the
relative name. | public static int | hashCode(Object object) Returns a hash code for an object, or zero if the object is
null .
Parameters: object - the object (null permitted). | public static boolean | isJDK14() | public static Object | loadAndInstantiate(String className, Class source) Tries to create a new instance of the given class. | public static Object | loadAndInstantiate(String className, Class source, Class type) Tries to create a new instance of the given class. | public static synchronized void | setClassLoader(ClassLoader classLoader) Redefines the custom classloader. | public static void | setClassLoaderSource(String classLoaderSource) Defines the internal configuration entry, whether the classloader of
the thread context or the context classloader should be used. |
CLASS_CONTEXT | final public static String CLASS_CONTEXT(Code) | | A constant for using the ClassContext as source for the classloader.
|
THREAD_CONTEXT | final public static String THREAD_CONTEXT(Code) | | A constant for using the TheadContext as source for the classloader.
|
clone | public static Object clone(Object object) throws CloneNotSupportedException(Code) | | Returns a clone of the specified object, if it can be cloned, otherwise
throws a CloneNotSupportedException.
Parameters: object - the object to clone (null not permitted). A clone of the specified object. throws: CloneNotSupportedException - if the object cannot be cloned. |
deepClone | public static Collection deepClone(Collection collection) throws CloneNotSupportedException(Code) | | Returns a new collection containing clones of all the items in the
specified collection.
Parameters: collection - the collection (null not permitted). A new collection containing clones of all the items in the specified collection. throws: CloneNotSupportedException - if any of the items in the collectioncannot be cloned. |
equal | public static boolean equal(Object o1, Object o2)(Code) | | Returns true if the two objects are equal OR both
null .
Parameters: o1 - object 1 (null permitted). Parameters: o2 - object 2 (null permitted). true or false . |
getClassLoader | public static ClassLoader getClassLoader()(Code) | | Returns the custom classloader or null, if no custom classloader is defined.
the custom classloader or null to use the default. |
getClassLoader | public static synchronized ClassLoader getClassLoader(Class c)(Code) | | Returns the classloader, which was responsible for loading the given
class.
Parameters: c - the classloader, either an application class loader or theboot loader. the classloader, never null. throws: SecurityException - if the SecurityManager does not allow to grabthe context classloader. |
getClassLoaderSource | public static String getClassLoaderSource()(Code) | | Returns the internal configuration entry, whether the classloader of
the thread context or the context classloader should be used.
the classloader source, either THREAD_CONTEXT or CLASS_CONTEXT. |
getResource | public static URL getResource(String name, Class c)(Code) | | Returns the resource specified by the absolute name.
Parameters: name - the name of the resource Parameters: c - the source class the url of the resource or null, if not found. |
getResourceAsStream | public static InputStream getResourceAsStream(String name, Class context)(Code) | | Returns the inputstream for the resource specified by the
absolute name.
Parameters: name - the name of the resource Parameters: context - the source class the url of the resource or null, if not found. |
getResourceRelative | public static URL getResourceRelative(String name, Class c)(Code) | | Returns the resource specified by the relative name.
Parameters: name - the name of the resource relative to the given class Parameters: c - the source class the url of the resource or null, if not found. |
getResourceRelativeAsStream | public static InputStream getResourceRelativeAsStream(String name, Class context)(Code) | | Returns the inputstream for the resource specified by the
relative name.
Parameters: name - the name of the resource relative to the given class Parameters: context - the source class the url of the resource or null, if not found. |
hashCode | public static int hashCode(Object object)(Code) | | Returns a hash code for an object, or zero if the object is
null .
Parameters: object - the object (null permitted). The object's hash code (or zero if the object isnull ). |
isJDK14 | public static boolean isJDK14()(Code) | | |
loadAndInstantiate | public static Object loadAndInstantiate(String className, Class source)(Code) | | Tries to create a new instance of the given class. This is a short cut
for the common bean instantiation code.
Parameters: className - the class name as String, never null. Parameters: source - the source class, from where to get the classloader. the instantiated object or null, if an error occured. |
loadAndInstantiate | public static Object loadAndInstantiate(String className, Class source, Class type)(Code) | | Tries to create a new instance of the given class. This is a short cut
for the common bean instantiation code. This method is a type-safe method
and will not instantiate the class unless it is an instance of the given
type.
Parameters: className - the class name as String, never null. Parameters: source - the source class, from where to get the classloader. the instantiated object or null, if an error occured. |
setClassLoader | public static synchronized void setClassLoader(ClassLoader classLoader)(Code) | | Redefines the custom classloader.
Parameters: classLoader - the new classloader or null to use the default. |
setClassLoaderSource | public static void setClassLoaderSource(String classLoaderSource)(Code) | | Defines the internal configuration entry, whether the classloader of
the thread context or the context classloader should be used.
This setting can only be defined using the API, there is no safe way
to put this into an external configuration file.
Parameters: classLoaderSource - the classloader source,either THREAD_CONTEXT or CLASS_CONTEXT. |
|
|