站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

ClassFile (Classfile Reader) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.classfile/1 1.19

org.netbeans.modules.classfile
Class ClassFile

java.lang.Object
  extended by org.netbeans.modules.classfile.ClassFile

public class ClassFile
extends Object

Class representing a Java class file.


Constructor Summary
ClassFile(File file, boolean includeCode)
          Create a new ClassFile object.
ClassFile(InputStream classData)
          Create a new ClassFile object.
ClassFile(InputStream classData, boolean includeCode)
          Create a new ClassFile object.
ClassFile(String classFileName)
          Create a new ClassFile object.
ClassFile(String classFileName, boolean includeCode)
          Create a new ClassFile object.
 
Method Summary
 int getAccess()
          Returns the access permissions of this class or interface.
 Set<ClassName> getAllClassNames()
          Return the collection of all unique class references in this class.
 Annotation getAnnotation(ClassName annotationClass)
          Returns the annotation for a specified annotation type, or null if no annotation of that type exists for this class.
 Collection<Annotation> getAnnotations()
          Returns all runtime annotations defined for this class.
 AttributeMap getAttributes()
          Returns a map of the raw attributes for this classfile.
 ConstantPool getConstantPool()
          Returns the ConstantPool object associated with this ClassFile.
 EnclosingMethod getEnclosingMethod()
          Returns the enclosing method for this class.
 Collection<InnerClass> getInnerClasses()
           
 Collection<ClassName> getInterfaces()
           
 int getMajorVersion()
          Returns the major version number of this classfile.
 Method getMethod(String name, String signature)
          Looks up a method by its name and type signature, as defined by the Java Virtual Machine Specification, section 4.3.3.
 int getMethodCount()
           
 Collection<Method> getMethods()
           
 int getMinorVersion()
          Returns the minor version number of this classfile.
 ClassName getName()
          Returns the name of this class.
 String getSourceFileName()
           
 ClassName getSuperClass()
          Returns the name of this class's superclass.
 String getTypeSignature()
          Returns the generic type information associated with this class.
 Variable getVariable(String name)
          Looks up a variable by its name.
 int getVariableCount()
           
 Collection<Variable> getVariables()
           
 boolean isAnnotation()
          Returns true if this class is an annotation type.
 boolean isAnnotationPresent(ClassName annotationClass)
          Returns true if an annotation of the specified type is defined for this class.
 boolean isDeprecated()
           
 boolean isEnum()
          Returns true if this class defines an enum type.
 boolean isSynthetic()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassFile

public ClassFile(InputStream classData)
          throws IOException
Create a new ClassFile object.

Parameters:
classData - an InputStream from which the defining bytes of this class or interface are read.
Throws:
IOException - if InputStream can't be read, or if the class data is malformed.

ClassFile

public ClassFile(String classFileName)
          throws IOException
Create a new ClassFile object.

Parameters:
classFileName - the path of a class file.
Throws:
IOException - if file cannot be opened or read.

ClassFile

public ClassFile(File file,
                 boolean includeCode)
          throws IOException
Create a new ClassFile object.

Parameters:
file - a File instance of a class file.
includeCode - true if this classfile should support operations at the bytecode level. Specify false to conserve memory if code access isn't needed.
Throws:
IOException - if file cannot be opened or read.

ClassFile

public ClassFile(InputStream classData,
                 boolean includeCode)
          throws IOException
Create a new ClassFile object.

Parameters:
classData - an InputStream from which the defining bytes of this class or interface are read.
includeCode - true if this classfile should support operations at the bytecode level. Specify false to conserve memory if code access isn't needed.
Throws:
IOException - if InputStream can't be read, or if the class data is malformed.

ClassFile

public ClassFile(String classFileName,
                 boolean includeCode)
          throws IOException
Create a new ClassFile object.

Parameters:
classFileName - the path of a class file.
includeCode - true if this classfile should support operations at the bytecode level. Specify false to conserve memory if code access isn't needed.
Throws:
IOException - if file cannot be opened or read.
Method Detail

getConstantPool

public final ConstantPool getConstantPool()
Returns the ConstantPool object associated with this ClassFile.

Returns:
the constant pool object

getAccess

public final int getAccess()
Returns the access permissions of this class or interface.

Returns:
a mask of access flags.
See Also:
Access

getName

public final ClassName getName()
Returns the name of this class.

Returns:
the name of this class.

getSuperClass

public final ClassName getSuperClass()
Returns the name of this class's superclass. A string is returned instead of a ClassFile object to reduce object creation.

Returns:
the name of the superclass of this class.

getInterfaces

public final Collection<ClassName> getInterfaces()
Returns:
a collection of Strings describing this class's interfaces.

getVariable

public final Variable getVariable(String name)
Looks up a variable by its name. NOTE: this method only looks up variables defined by this class, and not inherited from its superclass.

Parameters:
name - the name of the variable
Returns:
the variable,or null if no such variable in this class.

getVariables

public final Collection<Variable> getVariables()
Returns:
a Collection of Variable objects representing the fields defined by this class.

getVariableCount

public final int getVariableCount()
Returns:
the number of variables defined by this class.

getMethod

public final Method getMethod(String name,
                              String signature)
Looks up a method by its name and type signature, as defined by the Java Virtual Machine Specification, section 4.3.3. NOTE: this method only looks up methods defined by this class, and not methods inherited from its superclass.

Parameters:
name - the name of the method
signature - the method's type signature
Returns:
the method, or null if no such method in this class.

getMethods

public final Collection<Method> getMethods()
Returns:
a Collection of Method objects representing the methods defined by this class.

getMethodCount

public final int getMethodCount()
Returns:
the number of methods defined by this class.

getSourceFileName

public final String getSourceFileName()
Returns:
the name of the source file the compiler used to create this class.

isDeprecated

public final boolean isDeprecated()

isSynthetic

public final boolean isSynthetic()

isAnnotation

public final boolean isAnnotation()
Returns true if this class is an annotation type.


isEnum

public final boolean isEnum()
Returns true if this class defines an enum type.


getAttributes

public final AttributeMap getAttributes()
Returns a map of the raw attributes for this classfile. Field attributes are not returned in this map.

See Also:
Field.getAttributes()

getInnerClasses

public final Collection<InnerClass> getInnerClasses()

getMajorVersion

public int getMajorVersion()
Returns the major version number of this classfile.


getMinorVersion

public int getMinorVersion()
Returns the minor version number of this classfile.


getTypeSignature

public String getTypeSignature()
Returns the generic type information associated with this class. If this class does not have generic type information, then null is returned.


getEnclosingMethod

public EnclosingMethod getEnclosingMethod()
Returns the enclosing method for this class. A class will have an enclosing class if and only if it is a local class or an anonymous class, and has been compiled with a compiler target level of 1.5 or above. If no such attribute is present in the classfile, then null is returned.


getAnnotations

public final Collection<Annotation> getAnnotations()
Returns all runtime annotations defined for this class. Inherited annotations are not included in this collection.


getAnnotation

public final Annotation getAnnotation(ClassName annotationClass)
Returns the annotation for a specified annotation type, or null if no annotation of that type exists for this class.


isAnnotationPresent

public final boolean isAnnotationPresent(ClassName annotationClass)
Returns true if an annotation of the specified type is defined for this class.


getAllClassNames

public final Set<ClassName> getAllClassNames()
Return the collection of all unique class references in this class.

Returns:
a Set of ClassNames specifying the referenced classnames.

toString

public String toString()
Overrides:
toString in class Object

org.netbeans.modules.classfile/1 1.19

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.