1 package org.apache.beehive.controls.runtime.generator; 2 19 import java.util.Collection ; 20 21 import com.sun.mirror.declaration.FieldDeclaration; 22 import com.sun.mirror.declaration.Modifier; 23 24 28 public class AptField 29 { 30 AptField(FieldDeclaration fieldDecl) 31 { 32 _fieldDecl = fieldDecl; 33 } 34 35 38 public String getName() 39 { 40 if ( _fieldDecl == null ) 41 return ""; 42 return _fieldDecl.getSimpleName(); 43 } 44 45 48 public String getLocalName() { return "_" + getName(); } 49 50 53 public String getType() 54 { 55 if ( _fieldDecl == null || _fieldDecl.getType() == null ) 56 return ""; 57 58 return _fieldDecl.getType().toString(); 59 } 60 61 64 public String getClassName() 65 { 66 if ( _fieldDecl == null || _fieldDecl.getType() == null ) 67 return ""; 68 69 String typeName = _fieldDecl.getType().toString(); 73 int formalIndex = typeName.indexOf('<'); 74 if (formalIndex > 0) 75 return typeName.substring(0, formalIndex); 76 return typeName; 77 } 78 79 82 public String getAccessModifier() 83 { 84 if ( _fieldDecl == null ) 85 return ""; 86 87 Collection <Modifier> modifiers = _fieldDecl.getModifiers(); 88 if (modifiers.contains(Modifier.PRIVATE)) 89 return "private"; 90 if (modifiers.contains(Modifier.PROTECTED)) 91 return "protected"; 92 if (modifiers.contains(Modifier.PUBLIC)) 93 return "public"; 94 95 return ""; 96 } 97 98 101 public String getReflectField() 102 { 103 return "_" + getName() + "Field"; 104 } 105 106 protected FieldDeclaration _fieldDecl; 107 } 108 | Popular Tags |