Package edu.umd.cs.findbugs.ba
Class SignatureConverter
java.lang.Object
edu.umd.cs.findbugs.ba.SignatureConverter
Convert part or all of a Java type signature into something closer to what
types look like in the source code. Both field and method signatures may be
processed by this class. For a field signature, just call parseNext() once.
For a method signature, parseNext() must be called multiple times, and the
parens around the arguments must be skipped manually (by calling the skip()
method).
- Author:
- David Hovemeyer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Convenience method for converting a single signature component to human-readable form.static String
convertMethodSignature
(XMethod xmethod) Convenience method for generating a method signature in human readable form.static String
convertMethodSignature
(MethodDescriptor methodDescriptor) Convenience method for generating a method signature in human readable form.static String
convertMethodSignature
(String className, String methodName, String methodSig) Convenience method for generating a method signature in human readable form.static String
convertMethodSignature
(String className, String methodName, String methodSig, String pkgName) Convenience method for generating a method signature in human readable form.static String
convertMethodSignature
(org.apache.bcel.classfile.JavaClass javaClass, org.apache.bcel.classfile.Method method) Convenience method for generating a method signature in human readable form.static String
convertMethodSignature
(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg) Convenience method for generating a method signature in human readable form.static String
convertMethodSignature
(org.apache.bcel.generic.MethodGen methodGen) Convenience method for generating a method signature in human readable form.char
getFirst()
Get the first character of the remaining part of the signature.Parse a single type out of the signature, starting at the beginning of the remaining part of the signature.static String
void
skip()
Skip the first character of the remaining part of the signature.
-
Constructor Details
-
SignatureConverter
Constructor.- Parameters:
signature
- the field or method signature to convert
-
-
Method Details
-
getFirst
public char getFirst()Get the first character of the remaining part of the signature. -
skip
public void skip()Skip the first character of the remaining part of the signature. -
parseNext
Parse a single type out of the signature, starting at the beginning of the remaining part of the signature. For example, if the first character of the remaining part is "I", then this method will return "int", and the "I" will be consumed. Arrays, reference types, and basic types are all handled.- Returns:
- the parsed type string
-
convertMethodSignature
public static String convertMethodSignature(org.apache.bcel.classfile.JavaClass javaClass, org.apache.bcel.classfile.Method method) Convenience method for generating a method signature in human readable form.- Parameters:
javaClass
- the classmethod
- the method
-
convertMethodSignature
Convenience method for generating a method signature in human readable form.- Parameters:
methodGen
- the method to produce a method signature for
-
convertMethodSignature
public static String convertMethodSignature(org.apache.bcel.generic.InvokeInstruction inv, org.apache.bcel.generic.ConstantPoolGen cpg) Convenience method for generating a method signature in human readable form.- Parameters:
inv
- an InvokeInstructioncpg
- the ConstantPoolGen for the class the instruction belongs to
-
convertMethodSignature
Convenience method for generating a method signature in human readable form.- Parameters:
className
- name of the class containing the methodmethodName
- the name of the methodmethodSig
- the signature of the method
-
convertMethodSignature
Convenience method for generating a method signature in human readable form.- Parameters:
xmethod
- an XMethod- Returns:
- the formatted version of that signature
-
convertMethodSignature
Convenience method for generating a method signature in human readable form.- Parameters:
methodDescriptor
- a MethodDescriptor- Returns:
- the formatted version of that signature
-
convertMethodSignature
public static String convertMethodSignature(String className, String methodName, String methodSig, String pkgName) Convenience method for generating a method signature in human readable form.- Parameters:
className
- name of the class containing the methodmethodName
- the name of the methodmethodSig
- the signature of the methodpkgName
- the name of the package the method is in (used to shorten class names)
-
convert
Convenience method for converting a single signature component to human-readable form.- Parameters:
signature
- the signature
-
shorten
-