org.compass.core.config.binding.metadata
Class AsmClassMetaData

java.lang.Object
  extended by org.compass.core.util.asm.commons.EmptyVisitor
      extended by org.compass.core.config.binding.metadata.AsmClassMetaData
All Implemented Interfaces:
ClassMetaData, AnnotationVisitor, ClassVisitor, FieldVisitor, MethodVisitor

public class AsmClassMetaData
extends EmptyVisitor
implements ClassMetaData

An ASM based class meta data provider.

Author:
kimchy

Constructor Summary
AsmClassMetaData()
           
 
Method Summary
 Map<String,Object> getAnnotationAttributes(String annotationType)
          Retrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying class).
 Set<String> getAnnotationTypes()
          Return the names of all annotation types defined on the underlying class.
 String getClassName()
          Return the name of the underlying class.
 String getEnclosingClassName()
          Return the name of the enclosing class of the underlying class, or null if the underlying class is a top-level class.
 String[] getInterfaceNames()
          Return the name of all interfaces that the underlying class implements, or an empty array if there are none.
 Set<String> getMetaAnnotationTypes(String annotationType)
          Return the names of all meta-annotation types defined on the given annotation type of the underlying class.
 String getSuperClassName()
          Return the name of the super class of the underlying class, or null if there is no super class defined.
 boolean hasAnnotation(String annotationType)
          Determine whether the underlying class has an annotation of the given type defined.
 boolean hasEnclosingClass()
          Return whether the underlying class has an enclosing class (i.e. the underlying class is an inner/nested class or a local class within a method).
 boolean hasMetaAnnotation(String metaAnnotationType)
          Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.
 boolean hasSuperClass()
          Return whether the underlying class has a super class.
 boolean isAbstract()
          Return whether the underlying class is marked as abstract.
 boolean isConcrete()
          Return whether the underlying class represents a concrete class, i.e. neither an interface nor an abstract class.
 boolean isIndependent()
          Determine whether the underlying class is independent, i.e. whether it is a top-level class or a nested class (static inner class) that can be constructed independent from an enclosing class.
 boolean isInterface()
          Return whether the underlying class represents an interface.
 void visit(int version, int access, String name, String signature, String supername, String[] interfaces)
          Visits the header of the class.
 AnnotationVisitor visitAnnotation(String desc, boolean visible)
          Visits an annotation of the class.
 void visitInnerClass(String name, String outerName, String innerName, int access)
          Visits information about an inner class.
 void visitOuterClass(String owner, String name, String desc)
          Visits the enclosing class of the class.
 
Methods inherited from class org.compass.core.util.asm.commons.EmptyVisitor
visit, visitAnnotation, visitAnnotationDefault, visitArray, visitAttribute, visitCode, visitEnd, visitEnum, visitField, visitFieldInsn, visitFrame, visitIincInsn, visitInsn, visitIntInsn, visitJumpInsn, visitLabel, visitLdcInsn, visitLineNumber, visitLocalVariable, visitLookupSwitchInsn, visitMaxs, visitMethod, visitMethodInsn, visitMultiANewArrayInsn, visitParameterAnnotation, visitSource, visitTableSwitchInsn, visitTryCatchBlock, visitTypeInsn, visitVarInsn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsmClassMetaData

public AsmClassMetaData()
Method Detail

visit

public void visit(int version,
                  int access,
                  String name,
                  String signature,
                  String supername,
                  String[] interfaces)
Description copied from interface: ClassVisitor
Visits the header of the class.

Specified by:
visit in interface ClassVisitor
Overrides:
visit in class EmptyVisitor
Parameters:
version - the class version.
access - the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated.
name - the internal name of the class (see getInternalName).
signature - the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.
supername - the internal of name of the super class (see getInternalName). For interfaces, the super class is Object. May be null, but only for the Object class.
interfaces - the internal names of the class's interfaces (see getInternalName). May be null.

visitOuterClass

public void visitOuterClass(String owner,
                            String name,
                            String desc)
Description copied from interface: ClassVisitor
Visits the enclosing class of the class. This method must be called only if the class has an enclosing class.

Specified by:
visitOuterClass in interface ClassVisitor
Overrides:
visitOuterClass in class EmptyVisitor
Parameters:
owner - internal name of the enclosing class of the class.
name - the name of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.
desc - the descriptor of the method that contains the class, or null if the class is not enclosed in a method of its enclosing class.

visitInnerClass

public void visitInnerClass(String name,
                            String outerName,
                            String innerName,
                            int access)
Description copied from interface: ClassVisitor
Visits information about an inner class. This inner class is not necessarily a member of the class being visited.

Specified by:
visitInnerClass in interface ClassVisitor
Overrides:
visitInnerClass in class EmptyVisitor
Parameters:
name - the internal name of an inner class (see getInternalName).
outerName - the internal name of the class to which the inner class belongs (see getInternalName). May be null for not member classes.
innerName - the (simple) name of the inner class inside its enclosing class. May be null for anonymous inner classes.
access - the access flags of the inner class as originally declared in the enclosing class.

visitAnnotation

public AnnotationVisitor visitAnnotation(String desc,
                                         boolean visible)
Description copied from interface: ClassVisitor
Visits an annotation of the class.

Specified by:
visitAnnotation in interface ClassVisitor
Specified by:
visitAnnotation in interface FieldVisitor
Specified by:
visitAnnotation in interface MethodVisitor
Overrides:
visitAnnotation in class EmptyVisitor
Parameters:
desc - the class descriptor of the annotation class.
visible - true if the annotation is visible at runtime.
Returns:
a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.

getAnnotationTypes

public Set<String> getAnnotationTypes()
Description copied from interface: ClassMetaData
Return the names of all annotation types defined on the underlying class.

Specified by:
getAnnotationTypes in interface ClassMetaData
Returns:
the annotation type names

hasAnnotation

public boolean hasAnnotation(String annotationType)
Description copied from interface: ClassMetaData
Determine whether the underlying class has an annotation of the given type defined.

Specified by:
hasAnnotation in interface ClassMetaData
Parameters:
annotationType - the annotation type to look for
Returns:
whether a matching annotation is defined

getMetaAnnotationTypes

public Set<String> getMetaAnnotationTypes(String annotationType)
Description copied from interface: ClassMetaData
Return the names of all meta-annotation types defined on the given annotation type of the underlying class.

Specified by:
getMetaAnnotationTypes in interface ClassMetaData
Returns:
the meta-annotation type names

hasMetaAnnotation

public boolean hasMetaAnnotation(String metaAnnotationType)
Description copied from interface: ClassMetaData
Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.

Specified by:
hasMetaAnnotation in interface ClassMetaData
Parameters:
metaAnnotationType - the meta-annotation type to look for
Returns:
whether a matching meta-annotation is defined

getAnnotationAttributes

public Map<String,Object> getAnnotationAttributes(String annotationType)
Description copied from interface: ClassMetaData
Retrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying class).

Specified by:
getAnnotationAttributes in interface ClassMetaData
Parameters:
annotationType - the annotation type to look for
Returns:
a Map of attributes, with the attribute name as key (e.g. "value") and the defined attribute value as Map value. This return value will be null if no matching annotation is defined.

getClassName

public String getClassName()
Description copied from interface: ClassMetaData
Return the name of the underlying class.

Specified by:
getClassName in interface ClassMetaData

isInterface

public boolean isInterface()
Description copied from interface: ClassMetaData
Return whether the underlying class represents an interface.

Specified by:
isInterface in interface ClassMetaData

isAbstract

public boolean isAbstract()
Description copied from interface: ClassMetaData
Return whether the underlying class is marked as abstract.

Specified by:
isAbstract in interface ClassMetaData

isConcrete

public boolean isConcrete()
Description copied from interface: ClassMetaData
Return whether the underlying class represents a concrete class, i.e. neither an interface nor an abstract class.

Specified by:
isConcrete in interface ClassMetaData

isIndependent

public boolean isIndependent()
Description copied from interface: ClassMetaData
Determine whether the underlying class is independent, i.e. whether it is a top-level class or a nested class (static inner class) that can be constructed independent from an enclosing class.

Specified by:
isIndependent in interface ClassMetaData

hasEnclosingClass

public boolean hasEnclosingClass()
Description copied from interface: ClassMetaData
Return whether the underlying class has an enclosing class (i.e. the underlying class is an inner/nested class or a local class within a method).

If this method returns false, then the underlying class is a top-level class.

Specified by:
hasEnclosingClass in interface ClassMetaData

getEnclosingClassName

public String getEnclosingClassName()
Description copied from interface: ClassMetaData
Return the name of the enclosing class of the underlying class, or null if the underlying class is a top-level class.

Specified by:
getEnclosingClassName in interface ClassMetaData

hasSuperClass

public boolean hasSuperClass()
Description copied from interface: ClassMetaData
Return whether the underlying class has a super class.

Specified by:
hasSuperClass in interface ClassMetaData

getSuperClassName

public String getSuperClassName()
Description copied from interface: ClassMetaData
Return the name of the super class of the underlying class, or null if there is no super class defined.

Specified by:
getSuperClassName in interface ClassMetaData

getInterfaceNames

public String[] getInterfaceNames()
Description copied from interface: ClassMetaData
Return the name of all interfaces that the underlying class implements, or an empty array if there are none.

Specified by:
getInterfaceNames in interface ClassMetaData


Copyright (c) 2004-2008 The Compass Project.