Package com.mebigfatguy.fbcontrib.utils
Class SignatureUtils
java.lang.Object
com.mebigfatguy.fbcontrib.utils.SignatureUtils
a collection of static methods for parsing signatures to find information out
about them
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateprivate to reinforce the helper status of the class -
Method Summary
Modifier and TypeMethodDescriptionstatic StringclassToSignature(String className) returns a slashed or dotted class name into a signature, like java/lang/String -- Ljava/lang/String; Primitives and arrays are accepted.static booleancompareGenericSignature(String genericSignature, String regularSignature) private static org.apache.bcel.classfile.JavaClassfindInheritedMethod(org.apache.bcel.classfile.JavaClass[] classes, String methodName, String signature) static intgetFirstRegisterSlot(org.apache.bcel.classfile.Method m) returns the first open register slot after parametersstatic StringgetNonAnonymousPortion(String className) static intgetNumParameters(String methodSignature) returns the number of parameters in this method signaturestatic StringgetPackageName(String className) parses the package name from a fully qualified class namegetParameterSignatures(String methodSignature) returns a List of parameter signaturesgetParameterSlotAndSignatures(boolean methodIsStatic, String methodSignature) returns a Map that represents the type of the parameter in slot xstatic StringgetReturnSignature(String methodSig) gets the return type signature from a method signaturestatic intgetSignatureSize(String signature) static StringgetTypeCodeSignature(int typeCode) converts a primitive type code to a signaturestatic booleanisInheritedMethod(org.apache.bcel.classfile.JavaClass cls, String methodName, String signature) static booleanisPlainStringConvertableClass(String className) private static booleanisWonkyEclipseSignature(String sig, int startIndex) Eclipse makes weird class signatures.static booleansimilarPackages(String packName1, String packName2, int depth) returns whether or not the two packages have the same first 'depth' parts, if they existstatic StringstripSignature(String signature) converts a signature, like Ljava/lang/String; into a dotted class name.static StringtoArraySignature(String typeName) Converts a type name into an array signature.static StringtrimSignature(String signature) converts a signature, like Ljava/lang/String; into a slashed class name.
-
Field Details
-
PRIMITIVE_TYPES
-
TWO_SLOT_TYPES
-
CLASS_COMPONENT_DELIMITER
-
ANONYMOUS_COMPONENT
-
ECLIPSE_WEIRD_SIG_CHARS
- See Also:
-
PRIMITIVE_NAME_TO_SIG
-
-
Constructor Details
-
SignatureUtils
private SignatureUtils()private to reinforce the helper status of the class
-
-
Method Details
-
isInheritedMethod
public static boolean isInheritedMethod(org.apache.bcel.classfile.JavaClass cls, String methodName, String signature) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
getPackageName
parses the package name from a fully qualified class name- Parameters:
className- the class in question- Returns:
- the package of the class
-
similarPackages
returns whether or not the two packages have the same first 'depth' parts, if they exist- Parameters:
packName1- the first package to checkpackName2- the second package to checkdepth- the number of package parts to check- Returns:
- if they are similar
-
getTypeCodeSignature
converts a primitive type code to a signature- Parameters:
typeCode- the raw JVM type value- Returns:
- the signature of the type
-
findInheritedMethod
-
getParameterSlotAndSignatures
public static Map<Integer,String> getParameterSlotAndSignatures(boolean methodIsStatic, String methodSignature) returns a Map that represents the type of the parameter in slot x- Parameters:
methodIsStatic- if the method is static, causes where to start counting from, slot 0 or 1methodSignature- the signature of the method to parse- Returns:
- a map of parameter types (expect empty slots when doubles/longs are used
-
getParameterSignatures
returns a List of parameter signatures- Parameters:
methodSignature- the signature of the method to parse- Returns:
- a list of parameter signatures
-
getReturnSignature
gets the return type signature from a method signature- Parameters:
methodSig- the signature of the method- Returns:
- the signature of the return type, or ? if a bogus method signature is given
-
getNumParameters
returns the number of parameters in this method signature- Parameters:
methodSignature- the method signature to parse- Returns:
- the number of parameters
-
getFirstRegisterSlot
public static int getFirstRegisterSlot(org.apache.bcel.classfile.Method m) returns the first open register slot after parameters- Parameters:
m- the method for which you want the parameters- Returns:
- the first available register slot
-
compareGenericSignature
-
getSignatureSize
-
stripSignature
converts a signature, like Ljava/lang/String; into a dotted class name.- Parameters:
signature- a class signature, must not be null- Returns:
- the dotted class name
-
trimSignature
converts a signature, like Ljava/lang/String; into a slashed class name.- Parameters:
signature- the class signature- Returns:
- the slashed class name
-
classToSignature
returns a slashed or dotted class name into a signature, like java/lang/String -- Ljava/lang/String; Primitives and arrays are accepted.- Parameters:
className- the class name to convert- Returns:
- the signature format of the class
-
toArraySignature
Converts a type name into an array signature. Accepts slashed or dotted classnames, or type signatures.- Parameters:
typeName- the class name to generate an array signature from- Returns:
- the array signature
-
getNonAnonymousPortion
- Parameters:
className- the name of the class- Returns:
- the class name, discarding any anonymous component
-
isPlainStringConvertableClass
-
isWonkyEclipseSignature
Eclipse makes weird class signatures.- Parameters:
sig- the signature in type tablestartIndex- the index into the signature where the wonkyness begins- Returns:
- if this signature has eclipse meta chars
-