public class MethodToolkit
extends java.lang.Object
IMCType
and IMCMethod
implementations and to handle
conversion of reference types and field descriptors according to The Java Virtual Machine
Specification, Section 4.4.1 and Section 4.3.2, respectively, into Java type formats
according to The Java Language Specification, Sections 6.7 and 13.1.Modifier and Type | Field and Description |
---|---|
private static java.lang.String[] |
PRIMITIVE_TYPES |
private static java.lang.String |
TYPE_BOOLEAN |
private static java.lang.String |
TYPE_BYTE |
private static java.lang.String |
TYPE_CHAR |
private static java.lang.String |
TYPE_DOUBLE |
private static java.lang.String |
TYPE_FLOAT |
private static java.lang.String |
TYPE_INTEGER |
private static java.lang.String |
TYPE_LONG |
private static java.lang.String |
TYPE_SHORT |
private static java.lang.String |
TYPE_VOID |
Modifier | Constructor and Description |
---|---|
private |
MethodToolkit()
Do not instantiate.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
binaryNameToCanonical(java.lang.String binaryName)
Convert a binary name to a canonical name, as defined in The Java Language
Specification, Sections 6.7 and 13.1, respectively.
|
static int |
fieldDescToBinaryJLS(java.lang.CharSequence desc,
int start,
java.lang.Appendable out)
Convert the field descriptor, according to The Java Virtual Machine Specification,
Section 4.3.2, starting at position
start in desc , into a binary Java type
name according to The Java Language Specification, Section 13.1. |
static java.lang.String |
fieldDescToBinaryJLS(java.lang.String fieldDesc)
Convert a field descriptor according to The Java Virtual Machine Specification,
Section 4.3.2, into a binary Java type name according to The Java Language
Specification, Section 13.1.
|
static java.lang.String |
formatQualifiedName(IMCPackage mcPackage,
java.lang.String className)
Create a fully qualified class name based on a package.
|
private static java.lang.String |
formatQualifiedName(IMCPackage mcPackage,
java.lang.String className,
char separator)
Create a fully qualified class name based on a package.
|
static java.lang.Boolean |
hasNestedTypes(java.lang.String className)
Check if a class name denotes a nested class.
|
static java.lang.Boolean |
isArray(java.lang.String typeName)
Check if a type name denotes an array.
|
static boolean |
isDescOrRefArray(java.lang.String fieldDesc)
Check if a field descriptor or a reference type according to The Java Virtual Machine
Specification, Sections 4.3.2 and 4.4.1 respectively, designates an array.
|
static boolean |
isDescPrimitive(java.lang.String fieldDesc)
Check if a field descriptor according to The Java Virtual Machine Specification,
Section 4.3.2, designates a primitive type.
|
static boolean |
isPrimitive(java.lang.String typeName)
Check if a type name denotes a primitive type.
|
static java.lang.String |
nestedTypes(java.lang.String className)
Get the nested type name of a class.
|
static java.lang.String |
refTypeToBinaryJLS(java.lang.String refType)
Convert a reference type according to The Java Virtual Machine Specification, Section
4.4.1, into a binary Java type name according to The Java Language Specification,
Section 13.1.
|
static java.lang.String |
refTypeToFieldDescriptor(java.lang.String refType)
Convert a reference type according to The Java Virtual Machine Specification, Section
4.4.1, into a field descriptor according to The Java Virtual Machine Specification,
Section 4.3.2.
|
static java.lang.String |
topLevelType(java.lang.String className)
Get the top level type of a class.
|
static IMCType |
typeFromBinaryJLS(java.lang.String jlsType)
Convert a binary Java type name according to The Java Language Specification, Section
13.1, into an
IMCType . |
static IMCType |
typeFromReference(java.lang.String refType)
Convert a reference type according to The Java Virtual Machine Specification, Section
4.4.1, into an
IMCType . |
private static final java.lang.String TYPE_VOID
private static final java.lang.String TYPE_BOOLEAN
private static final java.lang.String TYPE_BYTE
private static final java.lang.String TYPE_CHAR
private static final java.lang.String TYPE_SHORT
private static final java.lang.String TYPE_INTEGER
private static final java.lang.String TYPE_LONG
private static final java.lang.String TYPE_FLOAT
private static final java.lang.String TYPE_DOUBLE
private static final java.lang.String[] PRIMITIVE_TYPES
public static boolean isPrimitive(java.lang.String typeName)
typeName
- type name to checktrue
if the type is primitive, false
if notpublic static java.lang.String formatQualifiedName(IMCPackage mcPackage, java.lang.String className)
mcPackage
- package for the classclassName
- class nameprivate static java.lang.String formatQualifiedName(IMCPackage mcPackage, java.lang.String className, char separator)
mcPackage
- package for the classclassName
- class nameseparator
- The separator to use between elements in the class name. Typically only '.' and
'/' are useful.public static java.lang.Boolean hasNestedTypes(java.lang.String className)
className
- class name to checktrue
if the class is nested, false
if notpublic static java.lang.String topLevelType(java.lang.String className)
className
- class name with possible nested componentspublic static java.lang.String nestedTypes(java.lang.String className)
className
- class name with possible nested componentsnull
if there is no nested classpublic static java.lang.Boolean isArray(java.lang.String typeName)
typeName
- type name to checktrue
if the type is an array, false
if notpublic static java.lang.String refTypeToFieldDescriptor(java.lang.String refType)
refType
- the reference type to convertpublic static java.lang.String binaryNameToCanonical(java.lang.String binaryName)
binaryName
- the binary name to convertpublic static java.lang.String refTypeToBinaryJLS(java.lang.String refType) throws java.lang.IllegalArgumentException
refType
- the reference type to convertjava.lang.IllegalArgumentException
- if refType
is not a valid reference typepublic static IMCType typeFromReference(java.lang.String refType) throws java.lang.IllegalArgumentException
IMCType
.refType
- the reference type to convertjava.lang.IllegalArgumentException
- if refType
is not a valid reference typepublic static IMCType typeFromBinaryJLS(java.lang.String jlsType) throws java.lang.IllegalArgumentException
IMCType
.jlsType
- the JLS type name to convertjava.lang.IllegalArgumentException
- if refType
is not a valid reference typepublic static java.lang.String fieldDescToBinaryJLS(java.lang.String fieldDesc) throws java.lang.IllegalArgumentException
fieldDesc
- the field descriptor (according to the JVM Specification) to convertjava.lang.IllegalArgumentException
- if fieldDesc
is not a valid field descriptorpublic static int fieldDescToBinaryJLS(java.lang.CharSequence desc, int start, java.lang.Appendable out) throws java.lang.IllegalArgumentException, java.io.IOException
start
in desc
, into a binary Java type
name according to The Java Language Specification, Section 13.1. and appends it to
out
.desc
- a CharSequence
containing the field descriptor (according to the JVM
Specification) to convertstart
- the position in desc
where the descriptor to convert startsout
- an Appendable
to which the result will be appendeddesc
not convertedjava.lang.IllegalArgumentException
- if desc
is not a valid field descriptorjava.io.IOException
- If an I/O error occurs when appending to out
. Note that this cannot
happen when using StringBuilder
or StringBuffer
.public static boolean isDescOrRefArray(java.lang.String fieldDesc)
fieldDesc
- a non-null field descriptor or reference type (according to the JVM Specification)public static boolean isDescPrimitive(java.lang.String fieldDesc)
fieldDesc
- a non-null field descriptor (according to the JVM Specification)