<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . Iterator ; import java . util . List ; public class TypeDeclaration extends AbstractTypeDeclaration { public static final ChildPropertyDescriptor JAVADOC_PROPERTY = internalJavadocPropertyFactory ( TypeDeclaration . class ) ; public static final SimplePropertyDescriptor MODIFIERS_PROPERTY = internalModifiersPropertyFactory ( TypeDeclaration . class ) ; public static final ChildListPropertyDescriptor MODIFIERS2_PROPERTY = internalModifiers2PropertyFactory ( TypeDeclaration . class ) ; public static final SimplePropertyDescriptor INTERFACE_PROPERTY = new SimplePropertyDescriptor ( TypeDeclaration . class , "interface" , boolean . class , MANDATORY ) ; public static final ChildPropertyDescriptor NAME_PROPERTY = internalNamePropertyFactory ( TypeDeclaration . class ) ; public static final ChildPropertyDescriptor SUPERCLASS_PROPERTY = new ChildPropertyDescriptor ( TypeDeclaration . class , "superclass" , Name . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor SUPER_INTERFACES_PROPERTY = new ChildListPropertyDescriptor ( TypeDeclaration . class , "" , Name . class , NO_CYCLE_RISK ) ; public static final ChildPropertyDescriptor SUPERCLASS_TYPE_PROPERTY = new ChildPropertyDescriptor ( TypeDeclaration . class , "" , Type . class , OPTIONAL , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor SUPER_INTERFACE_TYPES_PROPERTY = new ChildListPropertyDescriptor ( TypeDeclaration . class , "" , Type . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor TYPE_PARAMETERS_PROPERTY = new ChildListPropertyDescriptor ( TypeDeclaration . class , "" , TypeParameter . class , NO_CYCLE_RISK ) ; public static final ChildListPropertyDescriptor BODY_DECLARATIONS_PROPERTY = internalBodyDeclarationPropertyFactory ( TypeDeclaration . class ) ; private static final List PROPERTY_DESCRIPTORS_2_0 ; private static final List PROPERTY_DESCRIPTORS_3_0 ; static { List propertyList = new ArrayList ( 8 ) ; createPropertyList ( TypeDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS_PROPERTY , propertyList ) ; addProperty ( INTERFACE_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( SUPERCLASS_PROPERTY , propertyList ) ; addProperty ( SUPER_INTERFACES_PROPERTY , propertyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_2_0 = reapPropertyList ( propertyList ) ; propertyList = new ArrayList ( 9 ) ; createPropertyList ( TypeDeclaration . class , propertyList ) ; addProperty ( JAVADOC_PROPERTY , propertyList ) ; addProperty ( MODIFIERS2_PROPERTY , propertyList ) ; addProperty ( INTERFACE_PROPERTY , propertyList ) ; addProperty ( NAME_PROPERTY , propertyList ) ; addProperty ( TYPE_PARAMETERS_PROPERTY , propertyList ) ; addProperty ( SUPERCLASS_TYPE_PROPERTY , propertyList ) ; addProperty ( SUPER_INTERFACE_TYPES_PROPERTY , propertyList ) ; addProperty ( BODY_DECLARATIONS_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS_3_0 = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { if ( apiLevel == AST . JLS2_INTERNAL ) { return PROPERTY_DESCRIPTORS_2_0 ; } else { return PROPERTY_DESCRIPTORS_3_0 ; } } private boolean isInterface = false ; private ASTNode . NodeList typeParameters = null ; private Name optionalSuperclassName = null ; private ASTNode . NodeList superInterfaceNames = null ; private Type optionalSuperclassType = null ; private ASTNode . NodeList superInterfaceTypes = null ; TypeDeclaration ( AST ast ) { super ( ast ) ; if ( ast . apiLevel == AST . JLS2_INTERNAL ) { this . superInterfaceNames = new ASTNode . NodeList ( SUPER_INTERFACES_PROPERTY ) ; } if ( ast . apiLevel >= AST . JLS3 ) { this . typeParameters = new ASTNode . NodeList ( TYPE_PARAMETERS_PROPERTY ) ; this . superInterfaceTypes = new ASTNode . NodeList ( SUPER_INTERFACE_TYPES_PROPERTY ) ; } } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final int internalGetSetIntProperty ( SimplePropertyDescriptor property , boolean get , int value ) { if ( property == MODIFIERS_PROPERTY ) { if ( get ) { return getModifiers ( ) ; } else { internalSetModifiers ( value ) ; return 0 ; } } return super . internalGetSetIntProperty ( property , get , value ) ; } final boolean internalGetSetBooleanProperty ( SimplePropertyDescriptor property , boolean get , boolean value ) { if ( property == INTERFACE_PROPERTY ) { if ( get ) { return isInterface ( ) ; } else { setInterface ( value ) ; return false ; } } return super . internalGetSetBooleanProperty ( property , get , value ) ; } final ASTNode internalGetSetChildProperty ( ChildPropertyDescriptor property , boolean get , ASTNode child ) { if ( property == JAVADOC_PROPERTY ) { if ( get ) { return getJavadoc ( ) ; } else { setJavadoc ( ( Javadoc ) child ) ; return null ; } } if ( property == NAME_PROPERTY ) { if ( get ) { return getName ( ) ; } else { setName ( ( SimpleName ) child ) ; return null ; } } if ( property == SUPERCLASS_PROPERTY ) { if ( get ) { return getSuperclass ( ) ; } else { setSuperclass ( ( Name ) child ) ; return null ; } } if ( property == SUPERCLASS_TYPE_PROPERTY ) { if ( get ) { return getSuperclassType ( ) ; } else { setSuperclassType ( ( Type ) child ) ; return null ; } } return super . internalGetSetChildProperty ( property , get , child ) ; } final List internalGetChildListProperty ( ChildListPropertyDescriptor property ) { if ( property == MODIFIERS2_PROPERTY ) { return modifiers ( ) ; } if ( property == TYPE_PARAMETERS_PROPERTY ) { return typeParameters ( ) ; } if ( property == SUPER_INTERFACES_PROPERTY ) { return superInterfaces ( ) ; } if ( property == SUPER_INTERFACE_TYPES_PROPERTY ) { return superInterfaceTypes ( ) ; } if ( property == BODY_DECLARATIONS_PROPERTY ) { return bodyDeclarations ( ) ; } return super . internalGetChildListProperty ( property ) ; } final ChildPropertyDescriptor internalJavadocProperty ( ) { return JAVADOC_PROPERTY ; } final ChildListPropertyDescriptor internalModifiers2Property ( ) { return MODIFIERS2_PROPERTY ; } final SimplePropertyDescriptor internalModifiersProperty ( ) { return MODIFIERS_PROPERTY ; } final ChildPropertyDescriptor internalNameProperty ( ) { return NAME_PROPERTY ; } final ChildListPropertyDescriptor internalBodyDeclarationsProperty ( ) { return BODY_DECLARATIONS_PROPERTY ; } final int getNodeType0 ( ) { return TYPE_DECLARATION ; } ASTNode clone0 ( AST target ) { TypeDeclaration result = new TypeDeclaration ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setJavadoc ( ( Javadoc ) ASTNode . copySubtree ( target , getJavadoc ( ) ) ) ; if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { result . internalSetModifiers ( getModifiers ( ) ) ; result . setSuperclass ( ( Name ) ASTNode . copySubtree ( target , getSuperclass ( ) ) ) ; result . superInterfaces ( ) . addAll ( ASTNode . copySubtrees ( target , superInterfaces ( ) ) ) ; } result . setInterface ( isInterface ( ) ) ; result . setName ( ( SimpleName ) getName ( ) . clone ( target ) ) ; if ( this . ast . apiLevel >= AST . JLS3 ) { result . modifiers ( ) . addAll ( ASTNode . copySubtrees ( target , modifiers ( ) ) ) ; result . typeParameters ( ) . addAll ( ASTNode . copySubtrees ( target , typeParameters ( ) ) ) ; result . setSuperclassType ( ( Type ) ASTNode . copySubtree ( target , getSuperclassType ( ) ) ) ; result . superInterfaceTypes ( ) . addAll ( ASTNode . copySubtrees ( target , superInterfaceTypes ( ) ) ) ; } result . bodyDeclarations ( ) . addAll ( ASTNode . copySubtrees ( target , bodyDeclarations ( ) ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { boolean visitChildren = visitor . visit ( this ) ; if ( visitChildren ) { if ( this . ast . apiLevel == AST . JLS2_INTERNAL ) { acceptChild ( visitor , getJavadoc ( ) ) ; acceptChild ( visitor , getName ( ) ) ; acceptChild ( visitor , getSuperclass ( ) ) ; acceptChildren ( visitor , this . superInterfaceNames ) ; acceptChildren ( visitor , this . bodyDeclarations ) ; } if ( this . ast . apiLevel >= AST . JLS3 ) { acceptChild ( visitor , getJavadoc ( ) ) ; acceptChildren ( visitor , this . modifiers ) ; acceptChild ( visitor , getName ( ) ) ; acceptChildren ( visitor , this . typeParameters ) ; acceptChild ( visitor , getSuperclassType ( ) ) ; acceptChildren ( visitor , this . superInterfaceTypes ) ; acceptChildren ( visitor , this . bodyDeclarations ) ; } } visitor . endVisit ( this ) ; } public boolean isInterface ( ) { return this . isInterface ; } public void setInterface ( boolean isInterface ) { preValueChange ( INTERFACE_PROPERTY ) ; this . isInterface = isInterface ; postValueChange ( INTERFACE_PROPERTY ) ; } public List typeParameters ( ) { if ( this . typeParameters == null ) { unsupportedIn2 ( ) ; } return this . typeParameters ; } public Name getSuperclass ( ) { return internalGetSuperclass ( ) ; } final Name internalGetSuperclass ( ) { supportedOnlyIn2 ( ) ; return this . optionalSuperclassName ; } public Type getSuperclassType ( ) { unsupportedIn2 ( ) ; return this . optionalSuperclassType ; } public void setSuperclass ( Name superclassName ) { internalSetSuperclass ( superclassName ) ; } final void internalSetSuperclass ( Name superclassName ) { supportedOnlyIn2 ( ) ; ASTNode oldChild = this . optionalSuperclassName ; preReplaceChild ( oldChild , superclassName , SUPERCLASS_PROPERTY ) ; this . optionalSuperclassName = superclassName ; postReplaceChild ( oldChild , superclassName , SUPERCLASS_PROPERTY ) ; } public void setSuperclassType ( Type superclassType ) { unsupportedIn2 ( ) ; ASTNode oldChild = this . optionalSuperclassType ; preReplaceChild ( oldChild , superclassType , SUPERCLASS_TYPE_PROPERTY ) ; this . optionalSuperclassType = superclassType ; postReplaceChild ( oldChild , superclassType , SUPERCLASS_TYPE_PROPERTY ) ; } public List superInterfaces ( ) { return internalSuperInterfaces ( ) ; } final List internalSuperInterfaces ( ) { if ( this . superInterfaceNames == null ) { supportedOnlyIn2 ( ) ; } return this . superInterfaceNames ; } public List superInterfaceTypes ( ) { if ( this . superInterfaceTypes == null ) { unsupportedIn2 ( ) ; } return this . superInterfaceTypes ; } public FieldDeclaration [ ] getFields ( ) { List bd = bodyDeclarations ( ) ; int fieldCount = 0 ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { if ( it . next ( ) instanceof FieldDeclaration ) { fieldCount ++ ; } } FieldDeclaration [ ] fields = new FieldDeclaration [ fieldCount ] ; int next = 0 ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { Object decl = it . next ( ) ; if ( decl instanceof FieldDeclaration ) { fields [ next ++ ] = ( FieldDeclaration ) decl ; } } return fields ; } public MethodDeclaration [ ] getMethods ( ) { List bd = bodyDeclarations ( ) ; int methodCount = 0 ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { if ( it . next ( ) instanceof MethodDeclaration ) { methodCount ++ ; } } MethodDeclaration [ ] methods = new MethodDeclaration [ methodCount ] ; int next = 0 ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { Object decl = it . next ( ) ; if ( decl instanceof MethodDeclaration ) { methods [ next ++ ] = ( MethodDeclaration ) decl ; } } return methods ; } public TypeDeclaration [ ] getTypes ( ) { List bd = bodyDeclarations ( ) ; int typeCount = 0 ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { if ( it . next ( ) instanceof TypeDeclaration ) { typeCount ++ ; } } TypeDeclaration [ ] memberTypes = new TypeDeclaration [ typeCount ] ; int next = 0 ; for ( Iterator it = bd . listIterator ( ) ; it . hasNext ( ) ; ) { Object decl = it . next ( ) ; if ( decl instanceof TypeDeclaration ) { memberTypes [ next ++ ] = ( TypeDeclaration ) decl ; } } return memberTypes ; } ITypeBinding internalResolveBinding ( ) { return this . ast . getBindingResolver ( ) . resolveType ( this ) ; } int memSize ( ) { return super . memSize ( ) + 6 * 4 ; } int treeSize ( ) { return memSize ( ) + ( this . optionalDocComment == null ? 0 : getJavadoc ( ) . treeSize ( ) ) + ( this . modifiers == null ? 0 : this . modifiers . listSize ( ) ) + ( this . typeName == null ? 0 : getName ( ) . treeSize ( ) ) + ( this . typeParameters == null ? 0 : this . typeParameters . listSize ( ) ) + ( this . optionalSuperclassName == null ? 0 : getSuperclass ( ) . treeSize ( ) ) + ( this . optionalSuperclassType == null ? 0 : getSuperclassType ( ) . treeSize ( ) ) + ( this . superInterfaceNames == null ? 0 : this . superInterfaceNames . listSize ( ) ) + ( this . superInterfaceTypes == null ? 0 : this . superInterfaceTypes . listSize ( ) ) + this . bodyDeclarations . listSize ( ) ; } } </s>