1 52 53 package com.go.teatools; 54 55 import com.go.trove.classfile.AccessFlags; 56 57 import java.beans.*; 58 import java.lang.reflect.*; 59 60 69 public class TypeDescription extends FeatureDescription { 70 71 72 private Class mType; 73 74 75 private BeanInfo mBeanInfo; 76 77 82 public TypeDescription(Class type, TeaToolsUtils utils) { 83 super(utils); 84 mType = type; 85 } 86 87 90 public Class getType() { 91 return mType; 92 } 93 94 95 99 public AccessFlags getAccessFlags() { 100 return getTeaToolsUtils().getAccessFlags(mType.getModifiers()); 101 } 102 103 107 public String getFullName() { 108 return getTeaToolsUtils().getFullClassName(mType); 109 } 110 111 116 public String getName() { 117 return getTeaToolsUtils().getClassName(mType); 118 } 119 120 124 public String getPackage() { 125 return getTeaToolsUtils().getClassPackage(mType); 126 } 127 128 139 public String getTypeName() { 140 return getTeaToolsUtils().getClassTypeName(mType); 141 } 142 143 149 public String getVersion() { 150 return getTeaToolsUtils().getPackageVersion(getPackage()); 151 } 152 153 157 public TypeDescription getArrayType() { 158 159 Class c = getTeaToolsUtils().getArrayType(mType); 160 if (mType == c) { 161 return this; 162 } 163 164 return getTeaToolsUtils().createTypeDescription(c); 165 } 166 167 168 172 public int getArrayDimensions() { 173 return getTeaToolsUtils().getArrayDimensions(mType); 174 } 175 176 180 public String getArrayDimensionsString() { 181 return getTeaToolsUtils().getArrayDimensionsString(mType); 182 } 183 184 189 public BeanInfo getBeanInfo() { 190 if (mBeanInfo == null) { 191 try { 192 mBeanInfo = getTeaToolsUtils().getBeanInfo(mType); 193 } 194 catch (Exception e) { 195 return null; 196 } 197 } 198 199 return mBeanInfo; 200 } 201 202 210 public BeanInfo getBeanInfo(Class stopClass) 211 throws IntrospectionException { 212 return getTeaToolsUtils().getBeanInfo(mType, stopClass); 213 } 214 215 216 219 public PropertyDescriptor[] getPropertyDescriptors() { 220 BeanInfo info = getBeanInfo(); 221 if (info == null) { 222 return null; 223 } 224 225 PropertyDescriptor[] pds = info.getPropertyDescriptors(); 226 getTeaToolsUtils().sortPropertyDescriptors(pds); 227 return pds; 228 } 229 230 233 public PropertyDescription[] getPropertyDescriptions() { 234 return getTeaToolsUtils().createPropertyDescriptions( 235 getPropertyDescriptors()); 236 237 } 238 239 242 public PropertyDescriptor[] getTeaBeanPropertyDescriptors() { 243 return getTeaToolsUtils().getTeaBeanPropertyDescriptors(mType); 244 } 245 246 249 public PropertyDescription[] getTeaBeanPropertyDescriptions() { 250 return getTeaToolsUtils().createPropertyDescriptions( 251 getTeaBeanPropertyDescriptors()); 252 } 253 254 257 public MethodDescriptor[] getMethodDescriptors() { 258 BeanInfo info = getBeanInfo(); 259 if (info == null) { 260 return null; 261 } 262 263 MethodDescriptor[] mds = info.getMethodDescriptors(); 264 getTeaToolsUtils().sortMethodDescriptors(mds); 265 return mds; 266 } 267 268 271 public MethodDescription[] getMethodDescriptions() { 272 return getTeaToolsUtils().createMethodDescriptions( 273 getMethodDescriptors()); 274 } 275 276 277 282 public MethodDescriptor[] getTeaContextMethodDescriptors() { 283 return getTeaToolsUtils().getTeaContextMethodDescriptors(mType); 284 } 285 286 287 292 public MethodDescription[] getTeaContextMethodDescriptions() { 293 return getTeaToolsUtils().createMethodDescriptions( 294 getTeaContextMethodDescriptors()); 295 } 296 297 298 304 public MethodDescriptor[] getTeaContextMethodDescriptors( 305 boolean thisClassOnly) { 306 307 return getTeaToolsUtils().getTeaContextMethodDescriptors( 308 mType, 309 thisClassOnly); 310 } 311 312 318 public String getTeaFullName() { 319 return getTeaToolsUtils().getTeaFullClassName(mType); 320 } 321 322 330 public boolean isImplicitTeaImport() { 331 return getTeaToolsUtils().isImplicitTeaImport(mType); 332 } 333 334 339 public boolean isForeachCompatible() { 340 return getTeaToolsUtils().isForeachCompatible(mType); 341 } 342 343 347 public boolean isIfCompatible() { 348 return getTeaToolsUtils().isIfCompatible(mType); 349 } 350 351 355 public boolean isLikelyContextClass() { 356 return getTeaToolsUtils().isLikelyContextClass(mType); 357 } 358 359 360 364 public FeatureDescriptor getFeatureDescriptor() { 365 BeanInfo info = getBeanInfo(); 366 if (info == null) { 367 return null; 368 } 369 370 return info.getBeanDescriptor(); 371 } 372 373 374 public String getShortFormat() { 375 return getName(); 376 } 377 378 public String getLongFormat() { 379 return getFullName(); 380 } 381 382 383 384 } 385 386 387 388 389 | Popular Tags |