1 22 package org.jboss.aop.annotation.compiler; 23 24 import com.thoughtworks.qdox.model.AbstractJavaEntity; 25 import com.thoughtworks.qdox.model.DocletTag; 26 27 import org.jboss.aop.annotation.factory.duplicate.ast.ASTAnnotation; 28 import org.jboss.aop.annotation.factory.duplicate.ast.ASTStart; 29 import org.jboss.aop.annotation.factory.duplicate.ast.AnnotationParser; 30 import org.jboss.aop.annotation.factory.duplicate.ast.ParseException; 31 32 import java.io.StringReader ; 33 import java.util.Map ; 34 35 42 public class AnnotationDocletTag implements DocletTag 43 { 44 private static final long serialVersionUID = 1L; 45 46 private String name; 47 private final String value; 48 private final int lineNumber; 49 private ASTAnnotation ast; 50 51 private AbstractJavaEntity owner; 52 53 public AnnotationDocletTag(String name, String value, int lineNumber) 54 { 55 this.name = name; 56 this.value = value; 57 this.lineNumber = lineNumber; 58 if (name.startsWith("@")) 59 { 60 if (name.indexOf('(') != -1) 61 { 62 throw new RuntimeException ("illegal annotation syntax for doclet at line number " + lineNumber + ". You should have a space after the tag name otherwise the compiler messes up. " + name + " ***value=" + value); 63 70 } 71 AnnotationParser parser = new AnnotationParser(new StringReader (name + value)); 72 try 73 { 74 ASTStart start = parser.Start(); 75 ast = (ASTAnnotation) start.jjtGetChild(0); 76 } 77 catch (ParseException e) 78 { 79 throw new RuntimeException (e); } 81 this.name = name.substring(1); 82 } 83 } 84 85 public AnnotationDocletTag(String name, String value) 86 { 87 this(name, value, 0); 88 } 89 90 public ASTAnnotation getAnnotation() 91 { 92 return ast; 93 } 94 95 public String getName() 96 { 97 return name; 98 } 99 100 public String getValue() 101 { 102 return value; 103 } 104 105 public String [] getParameters() 106 { 107 return null; 108 } 109 110 public Map getNamedParameterMap() 111 { 112 return null; 113 } 114 115 public String getNamedParameter(String key) 116 { 117 return null; 118 } 119 120 public int getLineNumber() 121 { 122 return lineNumber; 123 } 124 125 public final AbstractJavaEntity getContext() 126 { 127 return owner; 128 } 129 130 public void setContext(AbstractJavaEntity owner) 131 { 132 this.owner = owner; 133 } 134 135 } 136 | Popular Tags |