org.clapper.util.classutil
Class ClassInfo

java.lang.Object
  extended by org.objectweb.asm.commons.EmptyVisitor
      extended by org.clapper.util.classutil.ClassInfo
All Implemented Interfaces:
org.objectweb.asm.AnnotationVisitor, org.objectweb.asm.ClassVisitor, org.objectweb.asm.FieldVisitor, org.objectweb.asm.MethodVisitor

public class ClassInfo
extends org.objectweb.asm.commons.EmptyVisitor

Holds information about a loaded class in a way that doesn't rely on the underlying API used to load the class information.

This class relies on the ASM byte-code manipulation library. If that library is not available, this package will not work. See asm.objectweb.org for details on ASM.

Version:
$Revision: 6735 $
Author:
Copyright © 2006 Brian M. Clapper

Constructor Summary
ClassInfo(java.io.File classFile)
          Create a ClassInfo object from a file.
ClassInfo(java.io.InputStream is)
          Create a ClassInfo object from an InputStream.
 
Method Summary
 java.io.File getClassLocation()
          Get the location (the jar file, zip file or directory) where the class was found.
 java.lang.String getClassName()
          Get the class name.
 java.lang.String[] getInterfaces()
          Get the names of all directly implemented interfaces.
 int getModifier()
          Get the Reflection API-based modifier bitfield for the class.
 java.lang.String getSuperClassName()
          Get the parent (super) class name, if any.
 java.lang.String toString()
          Get a string representation of this object.
 void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
          "Visit" a class.
 
Methods inherited from class org.objectweb.asm.commons.EmptyVisitor
visit, visitAnnotation, visitAnnotation, visitAnnotationDefault, visitArray, visitAttribute, visitCode, visitEnd, visitEnum, visitField, visitFieldInsn, visitIincInsn, visitInnerClass, visitInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLookupSwitchInsn, visitMaxs, visitMethod, visitMethodInsn, visitMultiANewArrayInsn, visitOuterClass, visitParameterAnnotation, visitSource, visitTableSwitchInsn, visitTryCatchBlock, visitTypeInsn, visitVarInsn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassInfo

public ClassInfo(java.io.File classFile)
          throws ClassUtilException
Create a ClassInfo object from a file.

Parameters:
classFile - the abstract path to the class file to load
Throws:
ClassUtilException - load error

ClassInfo

public ClassInfo(java.io.InputStream is)
          throws ClassUtilException
Create a ClassInfo object from an InputStream.

Parameters:
is - the open InputStream containing the class bytes
Throws:
ClassUtilException - load error
Method Detail

getClassName

public java.lang.String getClassName()
Get the class name.

Returns:
the class name

getSuperClassName

public java.lang.String getSuperClassName()
Get the parent (super) class name, if any. Returns null if the superclass is java.lang.Object. Note: To find other ancestor classes, use ClassFinder.findAllSuperClasses(org.clapper.util.classutil.ClassInfo, java.util.Map).

Returns:
the super class name, or null
See Also:
ClassFinder.findAllSuperClasses(org.clapper.util.classutil.ClassInfo, java.util.Map)

getInterfaces

public java.lang.String[] getInterfaces()
Get the names of all directly implemented interfaces. To find indirectly implemented interfaces, use ClassFinder.findAllInterfaces(org.clapper.util.classutil.ClassInfo, java.util.Map).

Returns:
an array of the names of all directly implemented interfaces, or null if there are none
See Also:
ClassFinder.findAllInterfaces(org.clapper.util.classutil.ClassInfo, java.util.Map)

getModifier

public int getModifier()
Get the Reflection API-based modifier bitfield for the class. Use java.lang.reflect.Modifier to decode this bitfield.

Returns:
the modifier

getClassLocation

public java.io.File getClassLocation()
Get the location (the jar file, zip file or directory) where the class was found.

Returns:
where the class was found

toString

public java.lang.String toString()
Get a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the string representation

visit

public void visit(int version,
                  int access,
                  java.lang.String name,
                  java.lang.String signature,
                  java.lang.String superName,
                  java.lang.String[] interfaces)
"Visit" a class. Required by ASM ClassVisitor interface.

Specified by:
visit in interface org.objectweb.asm.ClassVisitor
Overrides:
visit in class org.objectweb.asm.commons.EmptyVisitor
Parameters:
version - class version
access - class access modifiers, etc.
name - internal class name
signature - class signature (not used here)
superName - internal super class name
interfaces - internal names of all directly implemented interfaces


Copyright © 2004-2007 Brian M. Clapper. All Rights Reserved.