<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . IAnnotation ; import org . eclipse . jdt . core . IClassFile ; import org . eclipse . jdt . core . IMember ; import org . eclipse . jdt . core . IMemberValuePair ; import org . eclipse . jdt . core . ISourceRange ; import org . eclipse . jdt . core . JavaModelException ; import org . eclipse . jdt . core . SourceRange ; import org . eclipse . jdt . internal . compiler . env . IBinaryAnnotation ; import org . eclipse . jdt . internal . compiler . env . IBinaryElementValuePair ; import org . eclipse . jdt . internal . core . util . Util ; public class Annotation extends SourceRefElement implements IAnnotation { public static final IAnnotation [ ] NO_ANNOTATIONS = new IAnnotation [ 0 ] ; public static final IMemberValuePair [ ] NO_MEMBER_VALUE_PAIRS = new IMemberValuePair [ 0 ] ; protected String name ; protected String memberValuePairName ; public Annotation ( JavaElement parent , String name ) { this ( parent , name , null ) ; } public Annotation ( JavaElement parent , String name , String memberValuePairName ) { super ( parent ) ; this . name = name ; this . memberValuePairName = memberValuePairName ; } public boolean equals ( Object o ) { if ( ! ( o instanceof Annotation ) ) { return false ; } Annotation other = ( Annotation ) o ; if ( this . memberValuePairName == null ) { if ( other . memberValuePairName != null ) return false ; } else if ( ! this . memberValuePairName . equals ( other . memberValuePairName ) ) { return false ; } return super . equals ( o ) ; } public IMember getDeclaringMember ( ) { return ( IMember ) getParent ( ) ; } public String getElementName ( ) { return this . name ; } public int getElementType ( ) { return ANNOTATION ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_ANNOTATION ; } public IMemberValuePair [ ] getMemberValuePairs ( ) throws JavaModelException { Object info = getElementInfo ( ) ; if ( info instanceof AnnotationInfo ) return ( ( AnnotationInfo ) info ) . members ; IBinaryElementValuePair [ ] binaryAnnotations = ( ( IBinaryAnnotation ) info ) . getElementValuePairs ( ) ; int length = binaryAnnotations . length ; IMemberValuePair [ ] result = new IMemberValuePair [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { IBinaryElementValuePair binaryAnnotation = binaryAnnotations [ i ] ; MemberValuePair memberValuePair = new MemberValuePair ( new String ( binaryAnnotation . getName ( ) ) ) ; memberValuePair . value = Util . getAnnotationMemberValue ( this , memberValuePair , binaryAnnotation . getValue ( ) ) ; result [ i ] = memberValuePair ; } return result ; } public ISourceRange getNameRange ( ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { ClassFile classFile = ( ClassFile ) getClassFile ( ) ; if ( classFile != null ) { classFile . getBuffer ( ) ; return mapper . getNameRange ( this ) ; } } Object info = getElementInfo ( ) ; if ( info instanceof AnnotationInfo ) { AnnotationInfo annotationInfo = ( AnnotationInfo ) info ; return new SourceRange ( annotationInfo . nameStart , annotationInfo . nameEnd - annotationInfo . nameStart + 1 ) ; } return null ; } public ISourceRange getSourceRange ( ) throws JavaModelException { SourceMapper mapper = getSourceMapper ( ) ; if ( mapper != null ) { ClassFile classFile = ( ClassFile ) getClassFile ( ) ; if ( classFile != null ) { classFile . getBuffer ( ) ; return mapper . getSourceRange ( this ) ; } } return super . getSourceRange ( ) ; } public IClassFile getClassFile ( ) { return ( ( JavaElement ) getParent ( ) ) . getClassFile ( ) ; } public int hashCode ( ) { final int prime = 31 ; int result = super . hashCode ( ) ; result = prime * result + ( ( this . memberValuePairName == null ) ? 0 : this . memberValuePairName . hashCode ( ) ) ; result = prime * result + this . name . hashCode ( ) ; return result ; } protected void toStringName ( StringBuffer buffer ) { buffer . append ( '@' ) ; buffer . append ( getElementName ( ) ) ; } } </s>