<s> package org . eclipse . jdt . core . dom ; import java . util . ArrayList ; import java . util . List ; import org . eclipse . jdt . core . compiler . InvalidInputException ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . parser . Scanner ; import org . eclipse . jdt . internal . compiler . parser . TerminalTokens ; public class SimpleName extends Name { public static final SimplePropertyDescriptor IDENTIFIER_PROPERTY = new SimplePropertyDescriptor ( SimpleName . class , "identifier" , String . class , MANDATORY ) ; private static final List PROPERTY_DESCRIPTORS ; static { List propertyList = new ArrayList ( 2 ) ; createPropertyList ( SimpleName . class , propertyList ) ; addProperty ( IDENTIFIER_PROPERTY , propertyList ) ; PROPERTY_DESCRIPTORS = reapPropertyList ( propertyList ) ; } public static List propertyDescriptors ( int apiLevel ) { return PROPERTY_DESCRIPTORS ; } private static final String MISSING_IDENTIFIER = "MISSING" ; private String identifier = MISSING_IDENTIFIER ; SimpleName ( AST ast ) { super ( ast ) ; } final List internalStructuralPropertiesForType ( int apiLevel ) { return propertyDescriptors ( apiLevel ) ; } final Object internalGetSetObjectProperty ( SimplePropertyDescriptor property , boolean get , Object value ) { if ( property == IDENTIFIER_PROPERTY ) { if ( get ) { return getIdentifier ( ) ; } else { setIdentifier ( ( String ) value ) ; return null ; } } return super . internalGetSetObjectProperty ( property , get , value ) ; } final int getNodeType0 ( ) { return SIMPLE_NAME ; } ASTNode clone0 ( AST target ) { SimpleName result = new SimpleName ( target ) ; result . setSourceRange ( getStartPosition ( ) , getLength ( ) ) ; result . setIdentifier ( getIdentifier ( ) ) ; return result ; } final boolean subtreeMatch0 ( ASTMatcher matcher , Object other ) { return matcher . match ( this , other ) ; } void accept0 ( ASTVisitor visitor ) { visitor . visit ( this ) ; visitor . endVisit ( this ) ; } public String getIdentifier ( ) { return this . identifier ; } public void setIdentifier ( String identifier ) { if ( identifier == null ) { throw new IllegalArgumentException ( ) ; } Scanner scanner = this . ast . scanner ; long sourceLevel = scanner . sourceLevel ; long complianceLevel = scanner . complianceLevel ; try { scanner . sourceLevel = ClassFileConstants . JDK1_3 ; scanner . complianceLevel = ClassFileConstants . JDK1_5 ; char [ ] source = identifier . toCharArray ( ) ; scanner . setSource ( source ) ; final int length = source . length ; scanner . resetTo ( 0 , length - 1 ) ; try { int tokenType = scanner . scanIdentifier ( ) ; if ( tokenType != TerminalTokens . TokenNameIdentifier ) { throw new IllegalArgumentException ( ) ; } if ( scanner . currentPosition != length ) { throw new IllegalArgumentException ( ) ; } } catch ( InvalidInputException e ) { throw new IllegalArgumentException ( ) ; } } finally { this . ast . scanner . sourceLevel = sourceLevel ; this . ast . scanner . complianceLevel = complianceLevel ; } preValueChange ( IDENTIFIER_PROPERTY ) ; this . identifier = identifier ; postValueChange ( IDENTIFIER_PROPERTY ) ; } void internalSetIdentifier ( String ident ) { preValueChange ( IDENTIFIER_PROPERTY ) ; this . identifier = ident ; postValueChange ( IDENTIFIER_PROPERTY ) ; } public boolean isDeclaration ( ) { StructuralPropertyDescriptor d = getLocationInParent ( ) ; if ( d == null ) { return false ; } ASTNode parent = getParent ( ) ; if ( parent instanceof TypeDeclaration ) { return ( d == TypeDeclaration . NAME_PROPERTY ) ; } if ( parent instanceof MethodDeclaration ) { MethodDeclaration p = ( MethodDeclaration ) parent ; return ! p . isConstructor ( ) && ( d == MethodDeclaration . NAME_PROPERTY ) ; } if ( parent instanceof SingleVariableDeclaration ) { return ( d == SingleVariableDeclaration . NAME_PROPERTY ) ; } if ( parent instanceof VariableDeclarationFragment ) { return ( d == VariableDeclarationFragment . NAME_PROPERTY ) ; } if ( parent instanceof EnumDeclaration ) { return ( d == EnumDeclaration . NAME_PROPERTY ) ; } if ( parent instanceof EnumConstantDeclaration ) { return ( d == EnumConstantDeclaration . NAME_PROPERTY ) ; } if ( parent instanceof TypeParameter ) { return ( d == TypeParameter . NAME_PROPERTY ) ; } if ( parent instanceof AnnotationTypeDeclaration ) { return ( d == AnnotationTypeDeclaration . NAME_PROPERTY ) ; } if ( parent instanceof AnnotationTypeMemberDeclaration ) { return ( d == AnnotationTypeMemberDeclaration . NAME_PROPERTY ) ; } return false ; } void appendName ( StringBuffer buffer ) { buffer . append ( getIdentifier ( ) ) ; } int memSize ( ) { int size = BASE_NAME_NODE_SIZE + 2 * 4 ; if ( this . identifier != MISSING_IDENTIFIER ) { size += stringSize ( this . identifier ) ; } return size ; } int treeSize ( ) { return memSize ( ) ; } } </s>