com.go.trove.classfile
Class TypeDescriptor

java.lang.Object
  |
  +--com.go.trove.classfile.Descriptor
        |
        +--com.go.trove.classfile.TypeDescriptor

public class TypeDescriptor
extends Descriptor

This class is used to build field and return type descriptor strings as defined in The Java Virtual Machine Specification, section 4.3.2.

Version:
28 , 9/07/00
Author:
Brian S O'Neill
See Also:
ClassFile

Constructor Summary
TypeDescriptor(java.lang.Class clazz)
          Used to construct any kind of type descriptor including objects and primitive types.
TypeDescriptor(java.lang.String className)
           
TypeDescriptor(TypeDescriptor componentType, int dim)
          Used to construct an array TypeDescriptor.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 java.lang.Class getClassArg()
          If this TypeDescriptor was constructed with a Class argument, then this method retrieves that argument.
 java.lang.String getClassName()
           
 TypeDescriptor getComponentType()
          If this TypeDescriptor represents an array, the component type is returned.
 int getDimensions()
          Returns the dimensions after being adjusted.
 int getSpecifiedDimensions()
          Returns the dimensions as originally specified in the constructor.
 int hashCode()
           
static TypeDescriptor parseTypeDesc(java.lang.String desc)
           
 java.lang.String toString()
          Returns the TypeDescriptor code.
 
Methods inherited from class com.go.trove.classfile.Descriptor
parse
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypeDescriptor

public TypeDescriptor(java.lang.String className)

TypeDescriptor

public TypeDescriptor(java.lang.Class clazz)
Used to construct any kind of type descriptor including objects and primitive types.

TypeDescriptor

public TypeDescriptor(TypeDescriptor componentType,
                      int dim)
               throws java.lang.IllegalArgumentException
Used to construct an array TypeDescriptor.
Parameters:
componentType - the component type
dim - the number of dimensions, which must be greater than zero.
Throws:
java.lang.IllegalArgumentException - when the dimensions is not greater than zero.
Method Detail

getClassName

public java.lang.String getClassName()

getClassArg

public java.lang.Class getClassArg()
If this TypeDescriptor was constructed with a Class argument, then this method retrieves that argument. If the Class argument represented an array, the component type is returned. i.e. for TypeDescriptor(Object[][].class), Object is returned.

If this TypeDescriptor was constructed with a String argument, null is returned. Call getClassName instead in this case.

Returns:
A Class that never represents an array.

getComponentType

public TypeDescriptor getComponentType()
If this TypeDescriptor represents an array, the component type is returned. Otherwise, null is returned. i.e. for TypeDescriptor(Object[].class, 1), Object[] is returned, and for TypeDescriptor(Object[].class), Object is returned.

getDimensions

public int getDimensions()
Returns the dimensions after being adjusted. i.e. TypeDescriptor(Object[][].class) has two dimensions and TypeDescriptor(TypeDescriptor(Object[].class), 2) has three dimensions.

getSpecifiedDimensions

public int getSpecifiedDimensions()
Returns the dimensions as originally specified in the constructor. i.e. new TypeDescriptor(new TypeDescriptor(Object[].class), 2) has two specified dimensions. If no dimensions were specified, the results of getDimensions are returned.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns the TypeDescriptor code.
Overrides:
toString in class Descriptor

parseTypeDesc

public static TypeDescriptor parseTypeDesc(java.lang.String desc)
                                    throws java.lang.IllegalArgumentException