站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 4.0.0.11754MR2 API 英文版文档

ClassReader (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.asm
Class ClassReader

java.lang.Object
  extended by org.drools.asm.ClassReader

public class ClassReader
extends Object

A Java class parser to make a ClassVisitor visit an existing class. This class parses a byte array conforming to the Java class file format and calls the appropriate visit methods of a given class visitor for each field, method and bytecode instruction encountered.

Author:
Eric Bruneton, Eugene Kuleshov

Field Summary
 byte[] b
          The class to be parsed.
 int header
          Start index of the class header information (access, name...) in b.
 
Constructor Summary
ClassReader(byte[] b)
          Constructs a new ClassReader object.
ClassReader(byte[] b, int off, int len)
          Constructs a new ClassReader object.
ClassReader(InputStream is)
          Constructs a new ClassReader object.
ClassReader(String name)
          Constructs a new ClassReader object.
 
Method Summary
 void accept(ClassVisitor classVisitor, Attribute[] attrs, boolean skipDebug)
          Makes the given visitor visit the Java class of this ClassReader.
 void accept(ClassVisitor classVisitor, boolean skipDebug)
          Makes the given visitor visit the Java class of this ClassReader.
 int getItem(int item)
          Returns the start index of the constant pool item in b, plus one.
 int readByte(int index)
          Reads a byte value in b.
 String readClass(int index, char[] buf)
          Reads a class constant pool item in b.
 Object readConst(int item, char[] buf)
          Reads a numeric or string constant pool item in b.
 int readInt(int index)
          Reads a signed int value in b.
 long readLong(int index)
          Reads a signed long value in b.
 short readShort(int index)
          Reads a signed short value in b.
 int readUnsignedShort(int index)
          Reads an unsigned short value in b.
 String readUTF8(int index, char[] buf)
          Reads an UTF8 string constant pool item in b.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

b

public final byte[] b
The class to be parsed. The content of this array must not be modified. This field is intended for Attribute sub classes, and is normally not needed by class generators or adapters.


header

public final int header
Start index of the class header information (access, name...) in b.

Constructor Detail

ClassReader

public ClassReader(byte[] b)
Constructs a new ClassReader object.

Parameters:
b - the bytecode of the class to be read.

ClassReader

public ClassReader(byte[] b,
                   int off,
                   int len)
Constructs a new ClassReader object.

Parameters:
b - the bytecode of the class to be read.
off - the start offset of the class data.
len - the length of the class data.

ClassReader

public ClassReader(InputStream is)
            throws IOException
Constructs a new ClassReader object.

Parameters:
is - an input stream from which to read the class.
Throws:
IOException - if a problem occurs during reading.

ClassReader

public ClassReader(String name)
            throws IOException
Constructs a new ClassReader object.

Parameters:
name - the fully qualified name of the class to be read.
Throws:
IOException - if an exception occurs during reading.
Method Detail

accept

public void accept(ClassVisitor classVisitor,
                   boolean skipDebug)
Makes the given visitor visit the Java class of this ClassReader. This class is the one specified in the constructor (see ClassReader).

Parameters:
classVisitor - the visitor that must visit this class.
skipDebug - true if the debug information of the class must not be visited. In this case the visitLocalVariable and visitLineNumber methods will not be called.

accept

public void accept(ClassVisitor classVisitor,
                   Attribute[] attrs,
                   boolean skipDebug)
Makes the given visitor visit the Java class of this ClassReader. This class is the one specified in the constructor (see ClassReader).

Parameters:
classVisitor - the visitor that must visit this class.
attrs - prototypes of the attributes that must be parsed during the visit of the class. Any attribute whose type is not equal to the type of one the prototypes will be ignored.
skipDebug - true if the debug information of the class must not be visited. In this case the visitLocalVariable and visitLineNumber methods will not be called.

getItem

public int getItem(int item)
Returns the start index of the constant pool item in b, plus one. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
item - the index a constant pool item.
Returns:
the start index of the constant pool item in b, plus one.

readByte

public int readByte(int index)
Reads a byte value in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
index - the start index of the value to be read in b.
Returns:
the read value.

readUnsignedShort

public int readUnsignedShort(int index)
Reads an unsigned short value in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
index - the start index of the value to be read in b.
Returns:
the read value.

readShort

public short readShort(int index)
Reads a signed short value in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
index - the start index of the value to be read in b.
Returns:
the read value.

readInt

public int readInt(int index)
Reads a signed int value in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
index - the start index of the value to be read in b.
Returns:
the read value.

readLong

public long readLong(int index)
Reads a signed long value in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
index - the start index of the value to be read in b.
Returns:
the read value.

readUTF8

public String readUTF8(int index,
                       char[] buf)
Reads an UTF8 string constant pool item in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
index - the start index of an unsigned short value in b, whose value is the index of an UTF8 constant pool item.
buf - buffer to be used to read the item. This buffer must be sufficiently large. It is not automatically resized.
Returns:
the String corresponding to the specified UTF8 item.

readClass

public String readClass(int index,
                        char[] buf)
Reads a class constant pool item in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
index - the start index of an unsigned short value in b, whose value is the index of a class constant pool item.
buf - buffer to be used to read the item. This buffer must be sufficiently large. It is not automatically resized.
Returns:
the String corresponding to the specified class item.

readConst

public Object readConst(int item,
                        char[] buf)
Reads a numeric or string constant pool item in b. This method is intended for Attribute sub classes, and is normally not needed by class generators or adapters.

Parameters:
item - the index of a constant pool item.
buf - buffer to be used to read the item. This buffer must be sufficiently large. It is not automatically resized.
Returns:
the Integer, Float, Long, Double, String or Type corresponding to the given constant pool item.


Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.