org.codehaus.backport175.compiler.parser
Class AnnotationParser

java.lang.Object
  extended by org.codehaus.backport175.compiler.parser.AnnotationParser
All Implemented Interfaces:
AnnotationParserVisitor

public class AnnotationParser
extends java.lang.Object
implements AnnotationParserVisitor

The annotation visitor. Visits the annotation elements and adds them to the bytecode of the class.

Author:
Jonas Bon?r , Alexandre Vasseur

Field Summary
static java.lang.String DEFAULT_VALUE_NAME
          The default value's name.
protected  java.lang.Class m_annotationClass
          The top level annotation interface class.
protected  AnnotationVisitor m_bytecodeMunger
          The top level annotation bytecode munger.
protected static AnnotationParser PARSER
          The one and only annotation javadoc.
 
Method Summary
protected  java.lang.Class getElementTypeFor(java.lang.Class annotationInterface, java.lang.String valueName)
          Returns the expected type for an annotation value.
protected  void handleAnnotation(ASTAnnotation node, org.codehaus.backport175.compiler.parser.ParseContext ctx)
           
protected  java.lang.Object handleClassIdentifier(java.lang.String identifier, org.codehaus.backport175.compiler.parser.ParseContext ctx)
           
protected  void handleNestedAnnotation(ASTAnnotation node, org.codehaus.backport175.compiler.parser.ParseContext ctx)
           
protected  java.lang.Object handleReferenceIdentifier(java.lang.String identifier, org.codehaus.backport175.compiler.parser.ParseContext ctx)
           
protected  boolean isJavaReferenceType(java.lang.String valueAsString)
           
static void parse(AnnotationVisitor bytecodeMunger, RawAnnotation rawAnnotation)
          Parses the raw annotation.
static void parse(AnnotationVisitor bytecodeMunger, RawAnnotation rawAnnotation, java.lang.String desc)
          Parses the raw annotation for an annotation default value, whose type checking depends on the annotation element method desc if specified.
 java.lang.Object visit(ASTAnnotation node, java.lang.Object data)
           
 java.lang.Object visit(ASTArray node, java.lang.Object data)
           
 java.lang.Object visit(ASTBoolean node, java.lang.Object data)
           
 java.lang.Object visit(ASTChar node, java.lang.Object data)
           
 java.lang.Object visit(ASTFloat node, java.lang.Object data)
           
 java.lang.Object visit(ASTHex node, java.lang.Object data)
           
 java.lang.Object visit(ASTIdentifier node, java.lang.Object data)
           
 java.lang.Object visit(ASTInteger node, java.lang.Object data)
           
 java.lang.Object visit(ASTKeyValuePair node, java.lang.Object data)
           
 java.lang.Object visit(ASTOct node, java.lang.Object data)
           
 java.lang.Object visit(ASTRoot node, java.lang.Object data)
           
 java.lang.Object visit(ASTString node, java.lang.Object data)
           
 java.lang.Object visit(SimpleNode node, java.lang.Object data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_VALUE_NAME

public static final java.lang.String DEFAULT_VALUE_NAME
The default value's name.

See Also:
Constant Field Values

PARSER

protected static final AnnotationParser PARSER
The one and only annotation javadoc.


m_annotationClass

protected java.lang.Class m_annotationClass
The top level annotation interface class.


m_bytecodeMunger

protected AnnotationVisitor m_bytecodeMunger
The top level annotation bytecode munger.

Method Detail

parse

public static void parse(AnnotationVisitor bytecodeMunger,
                         RawAnnotation rawAnnotation)
Parses the raw annotation.

Parameters:
bytecodeMunger -
rawAnnotation -

parse

public static void parse(AnnotationVisitor bytecodeMunger,
                         RawAnnotation rawAnnotation,
                         java.lang.String desc)
Parses the raw annotation for an annotation default value, whose type checking depends on the annotation element method desc if specified.

Parameters:
bytecodeMunger -
rawAnnotation -
desc - expected type for annotation default value. If null, assume we visit a regular annotation

visit

public java.lang.Object visit(SimpleNode node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTRoot node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTAnnotation node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTKeyValuePair node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTIdentifier node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTBoolean node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTChar node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTString node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTInteger node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTFloat node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTHex node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTOct node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

visit

public java.lang.Object visit(ASTArray node,
                              java.lang.Object data)
Specified by:
visit in interface AnnotationParserVisitor

getElementTypeFor

protected java.lang.Class getElementTypeFor(java.lang.Class annotationInterface,
                                            java.lang.String valueName)
Returns the expected type for an annotation value.

Parameters:
annotationInterface -
valueName -
Returns:
the expected type

handleAnnotation

protected void handleAnnotation(ASTAnnotation node,
                                org.codehaus.backport175.compiler.parser.ParseContext ctx)

handleNestedAnnotation

protected void handleNestedAnnotation(ASTAnnotation node,
                                      org.codehaus.backport175.compiler.parser.ParseContext ctx)

handleClassIdentifier

protected java.lang.Object handleClassIdentifier(java.lang.String identifier,
                                                 org.codehaus.backport175.compiler.parser.ParseContext ctx)

handleReferenceIdentifier

protected java.lang.Object handleReferenceIdentifier(java.lang.String identifier,
                                                     org.codehaus.backport175.compiler.parser.ParseContext ctx)

isJavaReferenceType

protected boolean isJavaReferenceType(java.lang.String valueAsString)