1 18 package org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.declaration; 19 20 import org.apache.beehive.netui.compiler.typesystem.declaration.FieldDeclaration; 21 import org.apache.beehive.netui.compiler.typesystem.declaration.MethodDeclaration; 22 import org.apache.beehive.netui.compiler.typesystem.declaration.PackageDeclaration; 23 import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration; 24 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.WrapperFactory; 25 import org.apache.beehive.netui.compiler.typesystem.type.InterfaceType; 26 27 import java.util.Collection ; 28 import java.util.Iterator ; 29 30 import xjavadoc.XClass; 31 import xjavadoc.XField; 32 import xjavadoc.XMethod; 33 34 public class TypeDeclarationImpl 35 extends MemberDeclarationImpl 36 implements TypeDeclaration 37 { 38 private InterfaceType[] _superInterfaces; 39 private MethodDeclaration[] _methods; 40 private TypeDeclaration[] _nestedTypes; 41 private FieldDeclaration[] _fields; 42 43 public TypeDeclarationImpl( XClass delegate ) 44 { 45 super( delegate ); 46 } 47 48 public PackageDeclaration getPackage() 49 { 50 return WrapperFactory.get().getPackageDeclaration( getDelegateXClass().getContainingPackage() ); 51 } 52 53 public String getQualifiedName() 54 { 55 return getDelegateXClass().getQualifiedName(); 56 } 57 58 public InterfaceType[] getSuperinterfaces() 59 { 60 if ( _superInterfaces == null ) 61 { 62 Collection delegateCollection = getDelegateXClass().getSuperInterfaceElements(); 63 InterfaceType[] array = new InterfaceType[delegateCollection.size()]; 64 int j = 0; 65 for ( Iterator i = delegateCollection.iterator(); i.hasNext(); ) 66 { 67 array[j++] = WrapperFactory.get().getInterfaceType( ( XClass ) i.next() ); 68 } 69 _superInterfaces = array; 70 } 71 72 return _superInterfaces; 73 } 74 75 public FieldDeclaration[] getFields() 76 { 77 if ( _fields == null ) 78 { 79 Collection delegateCollection = getDelegateXClass().getFields(); 80 FieldDeclaration[] array = new FieldDeclaration[delegateCollection.size()]; 81 int j = 0; 82 for ( Iterator i = delegateCollection.iterator(); i.hasNext(); ) 83 { 84 array[j++] = WrapperFactory.get().getFieldDeclaration( ( XField ) i.next() ); 85 } 86 _fields = array; 87 } 88 89 return _fields; 90 } 91 92 public MethodDeclaration[] getMethods() 93 { 94 if ( _methods == null ) 95 { 96 Collection delegateCollection = getDelegateXClass().getMethods(); 97 MethodDeclaration[] array = new MethodDeclaration[delegateCollection.size()]; 98 int j = array.length; 99 100 for ( Iterator i = delegateCollection.iterator(); i.hasNext(); ) 102 { 103 array[--j] = WrapperFactory.get().getMethodDeclaration( ( XMethod ) i.next() ); 104 } 105 _methods = array; 106 } 107 108 return _methods; 109 } 110 111 public TypeDeclaration[] getNestedTypes() 112 { 113 if ( _nestedTypes == null ) 114 { 115 Collection delegateCollection = getDelegateXClass().getInnerClasses(); 116 TypeDeclaration[] array = new TypeDeclaration[delegateCollection.size()]; 117 int j = 0; 118 for ( Iterator i = delegateCollection.iterator(); i.hasNext(); ) 119 { 120 array[j++] = WrapperFactory.get().getTypeDeclaration( ( XClass ) i.next() ); 121 } 122 _nestedTypes = array; 123 } 124 125 return _nestedTypes; 126 } 127 128 public boolean equals( Object o ) 129 { 130 return super.equals( o ) || 131 ( o instanceof TypeDeclaration && ( ( TypeDeclaration ) o ).getQualifiedName().equals( getQualifiedName() )); 132 } 133 134 protected XClass getDelegateXClass() 135 { 136 return ( XClass ) super.getDelegate(); 137 } 138 } 139 | Popular Tags |