1 package org.apache.beehive.controls.runtime.generator; 2 19 20 import java.util.ArrayList ; 21 import java.util.Collection ; 22 23 import com.sun.mirror.declaration.AnnotationTypeDeclaration; 24 import com.sun.mirror.declaration.AnnotationTypeElementDeclaration; 25 import com.sun.mirror.declaration.MethodDeclaration; 26 import com.sun.mirror.declaration.Declaration; 27 28 import org.apache.beehive.controls.api.properties.PropertySet; 29 import org.apache.beehive.controls.runtime.generator.apt.TwoPhaseAnnotationProcessor; 30 31 35 public class AptPropertySet 36 { 37 43 public AptPropertySet(AptControlInterface controlIntf, Declaration propertySet, 44 TwoPhaseAnnotationProcessor ap) 45 { 46 _ap = ap; 47 _controlIntf = controlIntf; 48 49 if (!(propertySet instanceof AnnotationTypeDeclaration)) 50 { 51 _ap.printError( propertySet, "propertyset.illegal.usage" ); 52 return; 53 } 54 _propertySet = (AnnotationTypeDeclaration)propertySet; 55 56 _isOptional = _propertySet.getAnnotation(PropertySet.class).optional(); 57 _hasSetters = _propertySet.getAnnotation(PropertySet.class).hasSetters(); 58 59 _properties = initProperties(); 60 } 61 62 65 protected ArrayList <AptProperty> initProperties() 66 { 67 ArrayList <AptProperty> properties = new ArrayList <AptProperty>(); 68 69 if (_propertySet == null || _propertySet.getMethods() == null ) 70 return properties; 71 72 for (MethodDeclaration methodDecl : _propertySet.getMethods()) 74 if (!methodDecl.toString().equals("<clinit>()")) 75 properties.add( 76 new AptProperty(this,(AnnotationTypeElementDeclaration)methodDecl,_ap)); 77 78 return properties; 79 } 80 81 84 public Collection <AptProperty> getProperties() { return _properties; } 85 86 89 public String getPackage() 90 { 91 if (_propertySet == null || _propertySet.getPackage() == null ) 92 return ""; 93 94 return _propertySet.getPackage().getQualifiedName(); 95 } 96 97 100 public String getShortName() 101 { 102 if (_propertySet == null ) 103 return ""; 104 105 return _propertySet.getSimpleName(); 106 } 107 108 111 public String getClassName() 112 { 113 if (_propertySet == null ) 114 return ""; 115 116 return _propertySet.getQualifiedName(); 117 } 118 119 122 public String getPrefix() 123 { 124 if (_propertySet == null || _propertySet.getAnnotation(PropertySet.class) == null ) 125 return ""; 126 127 return _propertySet.getAnnotation(PropertySet.class).prefix(); 128 } 129 130 133 public boolean isOptional() 134 { 135 return _isOptional; 136 } 137 138 141 public boolean hasSetters() 142 { 143 return _hasSetters; 144 } 145 146 private AnnotationTypeDeclaration _propertySet; 147 private AptControlInterface _controlIntf; private ArrayList <AptProperty> _properties; 149 private TwoPhaseAnnotationProcessor _ap; 150 private boolean _isOptional; 151 private boolean _hasSetters; 152 } 153 | Popular Tags |