org.datanucleus.enhancer.asm
Class JdoClassChecker

java.lang.Object
  extended by org.datanucleus.enhancer.asm.JdoClassChecker
All Implemented Interfaces:
org.objectweb.asm.ClassVisitor

public class JdoClassChecker
extends java.lang.Object
implements org.objectweb.asm.ClassVisitor

Visitor used to check the enhancement state of a class. Checks the methods/fields present against what is required for JDO enhancement.


Field Summary
protected  boolean enhanced
          Flag for whether the class is enhanced.
protected  ASMClassEnhancer enhancer
          Enhancer for the class.
protected  java.util.HashSet fieldsRequired
          Set of fields required to be present for JDO.
protected static org.datanucleus.util.Localiser LOCALISER
          Message resource
protected  boolean logErrors
          Whether to log any errors at error level.
protected  java.util.HashSet methodsRequired
          Set of methods required to be present for JDO.
 
Constructor Summary
JdoClassChecker(ASMClassEnhancer enhancer, boolean logErrors)
          Constructor.
 
Method Summary
protected  boolean hasInterface(java.lang.String[] interfaces, java.lang.String intf)
          Convenience method to check if a particular interface is present in the list.
 boolean isEnhanced()
          Accessor for whether the class is considered enhanced.
protected  void reportError(java.lang.String msg)
          Convenience method to report an error in the enhancement of this class.
 void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String supername, java.lang.String[] interfaces)
          Method to visit the header of the class
 org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String desc, boolean visible)
          Method to visit a class annotations
 void visitAttribute(org.objectweb.asm.Attribute attr)
          Method to visit a non-standard attribute
 void visitEnd()
          Visit the end of the class
 org.objectweb.asm.FieldVisitor visitField(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.Object value)
          Visit a field of the class.
 void visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
          Visit an inner class of the class
 org.objectweb.asm.MethodVisitor visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
          Visit a method of the class
 void visitOuterClass(java.lang.String owner, java.lang.String name, java.lang.String desc)
          Visit an outer class.
 void visitSource(java.lang.String source, java.lang.String debug)
          Visit the source of the class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static org.datanucleus.util.Localiser LOCALISER
Message resource


enhancer

protected ASMClassEnhancer enhancer
Enhancer for the class.


fieldsRequired

protected java.util.HashSet fieldsRequired
Set of fields required to be present for JDO.


methodsRequired

protected java.util.HashSet methodsRequired
Set of methods required to be present for JDO.


enhanced

protected boolean enhanced
Flag for whether the class is enhanced. Set in the visit process.


logErrors

protected boolean logErrors
Whether to log any errors at error level.

Constructor Detail

JdoClassChecker

public JdoClassChecker(ASMClassEnhancer enhancer,
                       boolean logErrors)
Constructor.

Parameters:
enhancer - The class enhancer
logErrors - Whether to log any errors at error level
Method Detail

isEnhanced

public boolean isEnhanced()
Accessor for whether the class is considered enhanced. Should only be run after passing this class to the reader as a visitor.

Returns:
Whether the class is enhanced.

reportError

protected void reportError(java.lang.String msg)
Convenience method to report an error in the enhancement of this class.

Parameters:
msg - The message

visit

public void visit(int version,
                  int access,
                  java.lang.String name,
                  java.lang.String signature,
                  java.lang.String supername,
                  java.lang.String[] interfaces)
Method to visit the header of the class

Specified by:
visit in interface org.objectweb.asm.ClassVisitor
Parameters:
version - Version of the class file
access - Access type
name - name of the class
signature - signature of the class
supername - superclass name
interfaces - interface(s)

hasInterface

protected boolean hasInterface(java.lang.String[] interfaces,
                               java.lang.String intf)
Convenience method to check if a particular interface is present in the list.

Parameters:
interfaces - The list of interfaces implemented
intf - The interface we are looking for
Returns:
Whether it is present

visitAnnotation

public org.objectweb.asm.AnnotationVisitor visitAnnotation(java.lang.String desc,
                                                           boolean visible)
Method to visit a class annotations

Specified by:
visitAnnotation in interface org.objectweb.asm.ClassVisitor
Parameters:
desc - descriptor of the annotation
visible - Whether visible
Returns:
The visitor

visitAttribute

public void visitAttribute(org.objectweb.asm.Attribute attr)
Method to visit a non-standard attribute

Specified by:
visitAttribute in interface org.objectweb.asm.ClassVisitor
Parameters:
attr - the attribute

visitEnd

public void visitEnd()
Visit the end of the class

Specified by:
visitEnd in interface org.objectweb.asm.ClassVisitor

visitField

public org.objectweb.asm.FieldVisitor visitField(int access,
                                                 java.lang.String name,
                                                 java.lang.String desc,
                                                 java.lang.String signature,
                                                 java.lang.Object value)
Visit a field of the class.

Specified by:
visitField in interface org.objectweb.asm.ClassVisitor
Parameters:
access - Access for the field
name - name of the field
desc - Descriptor of the field
signature - signature of the field
value - initial value
Returns:
The visitor for the field

visitInnerClass

public void visitInnerClass(java.lang.String name,
                            java.lang.String outerName,
                            java.lang.String innerName,
                            int access)
Visit an inner class of the class

Specified by:
visitInnerClass in interface org.objectweb.asm.ClassVisitor
Parameters:
name - Internal name of the class
outerName - name of the outer class
innerName - name of the inner class
access - access of the inner class

visitMethod

public org.objectweb.asm.MethodVisitor visitMethod(int access,
                                                   java.lang.String name,
                                                   java.lang.String desc,
                                                   java.lang.String signature,
                                                   java.lang.String[] exceptions)
Visit a method of the class

Specified by:
visitMethod in interface org.objectweb.asm.ClassVisitor
Parameters:
access - Access for the field
name - name of the field
desc - Descriptor of the field
signature - signature of the field
exceptions - Exceptions thrown
Returns:
visitor for the method

visitOuterClass

public void visitOuterClass(java.lang.String owner,
                            java.lang.String name,
                            java.lang.String desc)
Visit an outer class.

Specified by:
visitOuterClass in interface org.objectweb.asm.ClassVisitor
Parameters:
owner - owner for the outer class
name - name of the outer class
desc - Descriptor of the outer class

visitSource

public void visitSource(java.lang.String source,
                        java.lang.String debug)
Visit the source of the class

Specified by:
visitSource in interface org.objectweb.asm.ClassVisitor
Parameters:
source - name of source file
debug - debug info


Copyright © 2009. All Rights Reserved.