Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.lang.reflect
Class TypeSignature  view TypeSignature download TypeSignature.java

java.lang.Object
  extended bygnu.java.lang.reflect.TypeSignature

public class TypeSignature
extends java.lang.Object

This class provides static methods that can be used to compute type-signatures of Classs or Members. More specific methods are also provided for computing the type-signature of Constructors and Methods. Methods are also provided to go in the reverse direction.


Constructor Summary
TypeSignature()
           
 
Method Summary
static java.lang.Class getClassForEncoding(java.lang.String type_code)
          Gets the Class object for a type name.
static java.lang.Class getClassForEncoding(java.lang.String type_code, boolean descriptor)
          This function is the inverse of getEncodingOfClass.
static java.lang.Class getClassForEncoding(java.lang.String type_code, boolean descriptor, java.lang.ClassLoader loader)
          This function is the inverse of getEncodingOfClass.
static java.lang.String getEncodingOfClass(java.lang.Class clazz)
          Gets the descriptor encoding for a class.
static java.lang.String getEncodingOfClass(java.lang.Class clazz, boolean descriptor)
          Gets the descriptor encoding for a class.
static java.lang.String getEncodingOfClass(java.lang.String type, boolean descriptor)
          Returns a String representing the type-encoding of a class.
static java.lang.String getEncodingOfConstructor(java.lang.reflect.Constructor c)
          Returns a String representing the type-encoding of a constructor.
static java.lang.String getEncodingOfMember(java.lang.reflect.Member mem)
          Returns a String representing the type-encoding of a class member.
static java.lang.String getEncodingOfMethod(java.lang.reflect.Method m)
          Returns a String representing the type-encoding of a method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeSignature

public TypeSignature()
Method Detail

getEncodingOfClass

public static java.lang.String getEncodingOfClass(java.lang.String type,
                                                  boolean descriptor)
Returns a String representing the type-encoding of a class. The .class file format has different encodings for classes, depending on whether it must be disambiguated from primitive types or not; hence the descriptor parameter to choose between them. If you are planning on decoding primitive types along with classes, then descriptor should be true for correct results. Type-encodings are computed as follows:
 boolean -> "Z"
 byte    -> "B"
 char    -> "C"
 double  -> "D"
 float   -> "F"
 int     -> "I"
 long    -> "J"
 short   -> "S"
 void    -> "V"
 arrays  -> "[" + descriptor format of component type
 object  -> class format: fully qualified name with '.' replaced by '/'
            descriptor format: "L" + class format + ";"
 


getEncodingOfClass

public static java.lang.String getEncodingOfClass(java.lang.Class clazz,
                                                  boolean descriptor)
Gets the descriptor encoding for a class.


getEncodingOfClass

public static java.lang.String getEncodingOfClass(java.lang.Class clazz)
Gets the descriptor encoding for a class.


getClassForEncoding

public static java.lang.Class getClassForEncoding(java.lang.String type_code,
                                                  boolean descriptor)
                                           throws java.lang.ClassNotFoundException
This function is the inverse of getEncodingOfClass. This accepts both object and descriptor formats, but must know which style of string is being passed in (usually, descriptor should be true). In descriptor format, "I" is treated as int.class, in object format, it is treated as a class named I in the unnamed package. This method is strictly equivalent to getClassForEncoding(java.lang.String, boolean, java.lang.ClassLoader) 55 with a class loader equal to null. In that case, it uses the default class loader on the calling stack.


getClassForEncoding

public static java.lang.Class getClassForEncoding(java.lang.String type_code,
                                                  boolean descriptor,
                                                  java.lang.ClassLoader loader)
                                           throws java.lang.ClassNotFoundException
This function is the inverse of getEncodingOfClass. This accepts both object and descriptor formats, but must know which style of string is being passed in (usually, descriptor should be true). In descriptor format, "I" is treated as int.class, in object format, it is treated as a class named I in the unnamed package.


getClassForEncoding

public static java.lang.Class getClassForEncoding(java.lang.String type_code)
                                           throws java.lang.ClassNotFoundException
Gets the Class object for a type name.


getEncodingOfMethod

public static java.lang.String getEncodingOfMethod(java.lang.reflect.Method m)
Returns a String representing the type-encoding of a method. The type-encoding of a method is: "(" + parameter type descriptors + ")" + return type descriptor XXX This could be faster if it were implemented natively.


getEncodingOfConstructor

public static java.lang.String getEncodingOfConstructor(java.lang.reflect.Constructor c)
Returns a String representing the type-encoding of a constructor. The type-encoding of a method is: "(" + parameter type descriptors + ")V" XXX This could be faster if it were implemented natively.


getEncodingOfMember

public static java.lang.String getEncodingOfMember(java.lang.reflect.Member mem)
Returns a String representing the type-encoding of a class member. This appropriately handles Constructors, Methods, and Fields.