jellyj.classfile.classgen
Class ClassGenType


public final class ClassGenType
implements Constants

Represents a basic or reference type (int, short, ..., objectref, arrayref)

Author:
JellyJ Design Group
See Also: Instruction

Constructor Summary
ClassGenType(byte type)
          Constructor for basic types such as int, long, `void'
ClassGenType(String class_name)
          Constructor for reference type, e.g.
ClassGenType(byte type, int dimensions)
          Constructor for array type, e.g.
ClassGenType(String class_name, int dimensions)
          Constructor for reference array type, e.g.
ClassGenType(ClassGenType type, int dimensions)
          Constructor for array of given type

Method Summary
 static ClassGenType[]getArgumentTypes(String signature)
          Convert arguments of a method (signature) to an array of ClassGenType objects.
 static StringgetMethodSignature(ClassGenType return_type, ClassGenType[] arg_types)
          Convert type to Java method signature, e.g.
 static ClassGenTypegetReturnType(String signature)
          Convert arguments of a method (signature) to an array of ClassGenType objects.
 StringgetSignature()
           
 StringtoString()
           

Constructor Detail

ClassGenType

public ClassGenType(byte type)
Constructor for basic types such as int, long, `void'
Parameters:
type - one of T_INT, T_BOOLEAN, ..., T_VOID

ClassGenType

public ClassGenType(String class_name)
Constructor for reference type, e.g. java.lang.String
Parameters:
class_name - String for complete class name

ClassGenType

public ClassGenType(byte type, int dimensions)
Constructor for array type, e.g. int[]
Parameters:
type - array type, e.g. T_INT

ClassGenType

public ClassGenType(String class_name, int dimensions)
Constructor for reference array type, e.g. Object[]
Parameters:
class_name - complete name of class (java.lang.String, e.g.)

ClassGenType

public ClassGenType(ClassGenType type, int dimensions)
Constructor for array of given type
Parameters:
type - type of array (may be an array itself)
Method Detail

getArgumentTypes

public static ClassGenType[] getArgumentTypes(String signature)
Convert arguments of a method (signature) to an array of ClassGenType objects.
Parameters:
signature - signature string such as (Ljava/lang/String;)V
Returns: array of argument types

getMethodSignature

public static String getMethodSignature(ClassGenType return_type, ClassGenType[] arg_types)
Convert type to Java method signature, e.g. int[] f(java.lang.String x) becomes (Ljava/lang/String;)[I
Parameters:
return_type - what the method returns
arg_types - what are the argument types
Returns: method signature for given type(s).

getReturnType

public static ClassGenType getReturnType(String signature)
Convert arguments of a method (signature) to an array of ClassGenType objects.
Parameters:
signature - signature string such as (Ljava/lang/String;)V
Returns: return type

getSignature

public String getSignature()
Returns: signature for given type.

toString

public String toString()
Returns: ClassGenType string, e.g. `int[]'

Association Links

to Class java.lang.String