|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.bcel.classfile.Utility
public abstract class Utility
Utility functions that do not really belong to any class in particular.
Constructor Summary | |
---|---|
Utility()
|
Method Summary | |
---|---|
static String |
accessToString(int access_flags)
Convert bit field of flags into string such as `static final'. |
static String |
accessToString(int access_flags,
boolean for_class)
Convert bit field of flags into string such as `static final'. |
static String |
classOrInterface(int access_flags)
|
static int |
clearBit(int flag,
int i)
|
static String |
codeToString(byte[] code,
ConstantPool constant_pool,
int index,
int length)
|
static String |
codeToString(byte[] code,
ConstantPool constant_pool,
int index,
int length,
boolean verbose)
Disassemble a byte array of JVM byte codes starting from code line `index' and return the disassembled string representation. |
static String |
codeToString(ByteSequence bytes,
ConstantPool constant_pool)
|
static String |
codeToString(ByteSequence bytes,
ConstantPool constant_pool,
boolean verbose)
Disassemble a stream of byte codes and return the string representation. |
static String |
compactClassName(String str)
Shorten long class names, java/lang/String becomes String. |
static String |
compactClassName(String str,
boolean chopit)
Shorten long class names, java/lang/String becomes java.lang.String, e.g.. |
static String |
compactClassName(String str,
String prefix,
boolean chopit)
Shorten long class name str, i.e., chop off the prefix, if the class name starts with this string and the flag chopit is true. |
static String |
convertString(String label)
Escape all occurences of newline chars '\n', quotes \", etc. |
static byte[] |
decode(String s,
boolean uncompress)
Decode a string back to a byte array. |
static String |
encode(byte[] bytes,
boolean compress)
Encode byte array it into Java identifier string, i.e., a string that only contains the following characters: (a, ... |
static String |
fillup(String str,
int length,
boolean left_justify,
char fill)
Fillup char with up to length characters with char `fill' and justify it left or right. |
static String |
format(int i,
int length,
boolean left_justify,
char fill)
Return a string for an integer justified left or right and filled up with `fill' characters if necessary. |
static String |
getSignature(String type)
Parse Java type such as "char", or "java.lang.String[]" and return the signature in byte code format, e.g. |
static boolean |
isJavaIdentifierPart(char ch)
|
static boolean |
isSet(int flag,
int i)
|
static String[] |
methodSignatureArgumentTypes(String signature)
|
static String[] |
methodSignatureArgumentTypes(String signature,
boolean chopit)
|
static String |
methodSignatureReturnType(String signature)
|
static String |
methodSignatureReturnType(String signature,
boolean chopit)
|
static String |
methodSignatureToString(String signature,
String name,
String access)
Converts method signature to string with all class names compacted. |
static String |
methodSignatureToString(String signature,
String name,
String access,
boolean chopit)
|
static String |
methodSignatureToString(String signature,
String name,
String access,
boolean chopit,
LocalVariableTable vars)
A return?type signature represents the return value from a method. |
static String |
methodTypeToSignature(String ret,
String[] argv)
Converts string containing the method return and argument types to a byte code method signature. |
static String |
printArray(Object[] obj)
|
static String |
printArray(Object[] obj,
boolean braces)
|
static String |
printArray(Object[] obj,
boolean braces,
boolean quote)
|
static void |
printArray(PrintStream out,
Object[] obj)
|
static void |
printArray(PrintWriter out,
Object[] obj)
|
static String |
replace(String str,
String old,
String new_)
Replace all occurences of old in str with new. |
static short |
searchOpcode(String name)
Map opcode names to opcode numbers. |
static int |
setBit(int flag,
int i)
|
static String |
signatureToString(String signature)
Converts signature to string with all class names compacted. |
static String |
signatureToString(String signature,
boolean chopit)
The field signature represents the value of an argument to a function or the value of a variable. |
static String |
toHexString(byte[] bytes)
Convert bytes into hexidecimal string |
static byte |
typeOfMethodSignature(String signature)
Return type of method signature as a byte value as defined in Constants |
static byte |
typeOfSignature(String signature)
Return type of signature as a byte value as defined in Constants |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utility()
Method Detail |
---|
public static final String accessToString(int access_flags)
access_flags
- Access flags
public static final String accessToString(int access_flags, boolean for_class)
access_flags
- Access flagsfor_class
- access flags are for class qualifiers ?
public static final String classOrInterface(int access_flags)
public static final String codeToString(byte[] code, ConstantPool constant_pool, int index, int length, boolean verbose)
code
- byte code arrayconstant_pool
- Array of constantsindex
- offset in `code' array
(number of opcodes, not bytes!)length
- number of opcodes to decompile, -1 for allverbose
- be verbose, e.g. print constant pool index
public static final String codeToString(byte[] code, ConstantPool constant_pool, int index, int length)
public static final String codeToString(ByteSequence bytes, ConstantPool constant_pool, boolean verbose) throws IOException
bytes
- stream of bytesconstant_pool
- Array of constantsverbose
- be verbose, e.g. print constant pool index
IOException
public static final String codeToString(ByteSequence bytes, ConstantPool constant_pool) throws IOException
IOException
public static final String compactClassName(String str)
str
- The long class name
public static final String compactClassName(String str, String prefix, boolean chopit)
str
- The long class nameprefix
- The prefix the get rid offchopit
- Flag that determines whether chopping is executed or not
public static final String compactClassName(String str, boolean chopit)
str
- The long class namechopit
- Flag that determines whether chopping is executed or not
public static final int setBit(int flag, int i)
public static final int clearBit(int flag, int i)
public static final boolean isSet(int flag, int i)
public static final String methodTypeToSignature(String ret, String[] argv) throws ClassFormatException
ret
- Return type of methodargv
- Types of method arguments
ClassFormatException
public static final String[] methodSignatureArgumentTypes(String signature) throws ClassFormatException
signature
- Method signature
ClassFormatException
public static final String[] methodSignatureArgumentTypes(String signature, boolean chopit) throws ClassFormatException
signature
- Method signaturechopit
- Shorten class names ?
ClassFormatException
public static final String methodSignatureReturnType(String signature) throws ClassFormatException
signature
- Method signature
ClassFormatException
public static final String methodSignatureReturnType(String signature, boolean chopit) throws ClassFormatException
signature
- Method signaturechopit
- Shorten class names ?
ClassFormatException
public static final String methodSignatureToString(String signature, String name, String access)
signature
- to convertname
- of methodaccess
- flags of method
public static final String methodSignatureToString(String signature, String name, String access, boolean chopit)
public static final String methodSignatureToString(String signature, String name, String access, boolean chopit, LocalVariableTable vars) throws ClassFormatException
signature
- Method signaturename
- Method nameaccess
- Method access rights
ClassFormatException
public static final String replace(String str, String old, String new_)
str
- String to permuteold
- String to be replacednew_
- Replacement string
public static final String signatureToString(String signature)
signature
- to convert
public static final String signatureToString(String signature, boolean chopit)
This method converts this string into a Java type declaration such as `String[]' and throws a `ClassFormatException' when the parsed type is invalid.::= ::= | | ::= B|C|D|F|I|J|S|Z ::= L ; ::= [ The meaning of the base types is as follows: B byte signed byte C char character D double double precision IEEE float F float single precision IEEE float I int integer J long long integer L ; ... an object of the given class S short signed short Z boolean true or false [ ... array
signature
- Class signaturechopit
- Flag that determines whether chopping is executed or not
ClassFormatException
public static String getSignature(String type)
type
- Java type
public static final byte typeOfMethodSignature(String signature) throws ClassFormatException
signature
- in format described above
ClassFormatException
Constants
public static final byte typeOfSignature(String signature) throws ClassFormatException
signature
- in format described above
ClassFormatException
Constants
public static short searchOpcode(String name)
public static final String toHexString(byte[] bytes)
public static final String format(int i, int length, boolean left_justify, char fill)
i
- integer to formatlength
- length of desired stringleft_justify
- format left or rightfill
- fill character
public static final String fillup(String str, int length, boolean left_justify, char fill)
str
- string to formatlength
- length of desired stringleft_justify
- format left or rightfill
- fill character
public static final void printArray(PrintStream out, Object[] obj)
public static final void printArray(PrintWriter out, Object[] obj)
public static final String printArray(Object[] obj)
public static final String printArray(Object[] obj, boolean braces)
public static final String printArray(Object[] obj, boolean braces, boolean quote)
public static boolean isJavaIdentifierPart(char ch)
public static String encode(byte[] bytes, boolean compress) throws IOException
This operation inflates the original byte array by roughly 40-50%
bytes
- the byte array to convertcompress
- use gzip to minimize string
IOException
public static byte[] decode(String s, boolean uncompress) throws IOException
s
- the string to convertuncompress
- use gzip to uncompress the stream of bytes
IOException
public static final String convertString(String label)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |