1 package org.apache.beehive.controls.runtime.generator; 2 19 20 import java.io.IOException ; 21 import java.util.Collection ; 22 import java.util.HashMap ; 23 import java.util.List ; 24 25 import com.sun.mirror.apt.Filer; 26 import com.sun.mirror.declaration.TypeDeclaration; 27 import com.sun.mirror.declaration.TypeParameterDeclaration; 28 29 33 public class AptType 34 { 35 38 protected void setDeclaration(TypeDeclaration typeDecl) 39 { 40 _typeDecl = typeDecl; 41 } 42 43 46 public String getClassName() 47 { 48 if ( _typeDecl == null) 49 return ""; 50 51 return _typeDecl.getQualifiedName(); 52 } 53 54 57 public String getPackage() 58 { 59 if ( _typeDecl == null) 60 return ""; 61 62 return _typeDecl.getPackage().getQualifiedName(); 63 } 64 65 68 public String getShortName() 69 { 70 if ( _typeDecl == null ) 71 return ""; 72 73 return _typeDecl.getSimpleName(); 74 } 75 76 79 private String getFormalTypeParameters(boolean namesOnly) 80 { 81 Collection <TypeParameterDeclaration> ftColl = _typeDecl.getFormalTypeParameters(); 82 if (ftColl.size() == 0) 83 return ""; 84 85 StringBuffer sb = new StringBuffer ("<"); 86 boolean isFirst = true; 87 for (TypeParameterDeclaration tpDecl : ftColl) 88 { 89 if (!isFirst) 90 sb.append(","); 91 else 92 isFirst = false; 93 94 if (namesOnly) 95 sb.append(tpDecl.getSimpleName()); 96 else 97 sb.append(tpDecl.toString()); 98 } 99 sb.append(">"); 100 return sb.toString(); 101 } 102 103 106 public String getFormalTypeParameters() 107 { 108 return getFormalTypeParameters(false); 109 } 110 111 114 public String getFormalTypeParameterNames() 115 { 116 return getFormalTypeParameters(true); 117 } 118 119 124 public String getFormalShortName() 125 { 126 StringBuffer sb = new StringBuffer (getShortName()); 127 sb.append(getFormalTypeParameterNames()); 128 return sb.toString(); 129 } 130 131 136 public String getFormalClassName() 137 { 138 StringBuffer sb = new StringBuffer (getClassName()); 139 sb.append(getFormalTypeParameterNames()); 140 return sb.toString(); 141 } 142 143 146 public TypeDeclaration getTypeDeclaration() 147 { 148 return _typeDecl; 149 } 150 151 TypeDeclaration _typeDecl; 152 } 153 | Popular Tags |