Copyright 2002 by aragost

com.aragost.lang
Class Classes

java.lang.Object
  |
  +--com.aragost.lang.Classes

public abstract class Classes
extends java.lang.Object

Utility class with variaous functions working on classes and interfaces


Constructor Summary
Classes()
           
 
Method Summary
static java.util.Iterator allInterfaces(java.lang.Class clazz)
          Return an Iterator that will iterate over all interfaces implemented by the receiver.
static int getArrayDimension(java.lang.Class c)
          Return the dimension of the specified Array class.
static java.io.File getBase(java.lang.Class clazz)
          Try to figure out where the specified class is loaded from.
static java.lang.String getName(java.lang.Class clazz)
          Return the name of the specified Class.
static java.lang.String getName(java.lang.Class clazz, java.util.Collection names)
          Return the name of the specified Class.
static java.lang.String getName(java.lang.Object instance, java.lang.Class clazz)
          Return the name of the specified Class.
static java.lang.String getName(java.lang.Object instance, java.lang.Class clazz, java.util.Collection names)
          Return the name of the specified class.
static java.lang.Class getPrimitiveClass(java.lang.Class clazz)
          Return the primitive class associated with the specified wrapper class.
static java.lang.String getResourceName(java.lang.Class clazz)
          Return the name of the resource that was loaded to create this class.
static java.lang.Class getRootComponentType(java.lang.Class c)
          Return the "root" component type of the specified array class.
static java.lang.Class getWrapperClass(java.lang.Class clazz)
          Return the wrapper class associated with the specified primitive class.
static boolean isWrapperClass(java.lang.Class clazz)
          Check if the specified class is a wrapper class for a primitive class
static java.lang.Class[] primitives()
          Return an array with all primitive classes
static java.util.Iterator superclasses(java.lang.Class clazz)
          Return an Iterator that iterate from the specified class through the superclass chain to the class Object.class.
static java.util.Iterator traverse(java.io.File root)
           
static java.util.Iterator traverseZip(java.io.File zipFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Classes

public Classes()
Method Detail

isWrapperClass

public static boolean isWrapperClass(java.lang.Class clazz)
Check if the specified class is a wrapper class for a primitive class

Parameters:
clazz - The Class to check
Returns:
true if the specified class is a wrapper class for a primitive type

getPrimitiveClass

public static java.lang.Class getPrimitiveClass(java.lang.Class clazz)
Return the primitive class associated with the specified wrapper class. If the specified class is not a wrapper class, then return the class itself

Parameters:
clazz -
Returns:
the primitive type corresponding to the specified class.

getWrapperClass

public static java.lang.Class getWrapperClass(java.lang.Class clazz)
Return the wrapper class associated with the specified primitive class. If the specified class is not a primitive class, then return the class.


primitives

public static java.lang.Class[] primitives()
Return an array with all primitive classes


allInterfaces

public static java.util.Iterator allInterfaces(java.lang.Class clazz)
Return an Iterator that will iterate over all interfaces implemented by the receiver.


superclasses

public static java.util.Iterator superclasses(java.lang.Class clazz)
Return an Iterator that iterate from the specified class through the superclass chain to the class Object.class. The specified Class is the first Object returned by the Iterator.


traverse

public static java.util.Iterator traverse(java.io.File root)

traverseZip

public static java.util.Iterator traverseZip(java.io.File zipFile)
                                      throws java.util.zip.ZipException,
                                             java.io.IOException
java.util.zip.ZipException
java.io.IOException

getName

public static java.lang.String getName(java.lang.Object instance,
                                       java.lang.Class clazz,
                                       java.util.Collection names)
Return the name of the specified class. The difference to the getName() method in Class is: If the specified class is an array class a String of the form "name[][]" is returned. If the specified instance is not null, it is assumed it is an instance of the specified class, and the instance is used to fill in size in the class name (e.g. String[10][2]). The package name is not returned as part of the class name if the package is in the specified collection of packages names. If no names are specified (argument is null) then a Collection with java.lang is used

Parameters:
instance - An instance of the specified class, can be null
clazz - The class to return the name of
names - A Collection of package names.
Returns:
The name of the class

getName

public static java.lang.String getName(java.lang.Class clazz)
Return the name of the specified Class.

See Also:
getName(Object, Class, Collection)

getName

public static java.lang.String getName(java.lang.Class clazz,
                                       java.util.Collection names)
Return the name of the specified Class.

See Also:
getName(Object, Class, Collection)

getName

public static java.lang.String getName(java.lang.Object instance,
                                       java.lang.Class clazz)
Return the name of the specified Class.

See Also:
getName(Object, Class, Collection)

getArrayDimension

public static int getArrayDimension(java.lang.Class c)
Return the dimension of the specified Array class. If the class is not an array class zero is returned.


getRootComponentType

public static java.lang.Class getRootComponentType(java.lang.Class c)
Return the "root" component type of the specified array class. If the class is not an array class the class it self is returned.


getResourceName

public static java.lang.String getResourceName(java.lang.Class clazz)
Return the name of the resource that was loaded to create this class. The name is returned with a leading '/'.


getBase

public static java.io.File getBase(java.lang.Class clazz)
Try to figure out where the specified class is loaded from. Returns either a directory or a jar file. If the specified class is not loaded from the local file system, then null is returned.


Copyright 2002 by aragost