<s> package org . eclipse . jdt . internal . compiler . lookup ; import org . eclipse . jdt . internal . compiler . ast . * ; import org . eclipse . jdt . internal . compiler . classfmt . ClassFileConstants ; import org . eclipse . jdt . internal . compiler . impl . Constant ; public class ElementValuePair { char [ ] name ; public Object value ; public MethodBinding binding ; public static Object getValue ( Expression expression ) { if ( expression == null ) return null ; Constant constant = expression . constant ; if ( constant != null && constant != Constant . NotAConstant ) return constant ; if ( expression instanceof Annotation ) return ( ( Annotation ) expression ) . getCompilerAnnotation ( ) ; if ( expression instanceof ArrayInitializer ) { Expression [ ] exprs = ( ( ArrayInitializer ) expression ) . expressions ; int length = exprs == null ? 0 : exprs . length ; Object [ ] values = new Object [ length ] ; for ( int i = 0 ; i < length ; i ++ ) values [ i ] = getValue ( exprs [ i ] ) ; return values ; } if ( expression instanceof ClassLiteralAccess ) return ( ( ClassLiteralAccess ) expression ) . targetType ; if ( expression instanceof Reference ) { FieldBinding fieldBinding = null ; if ( expression instanceof FieldReference ) { fieldBinding = ( ( FieldReference ) expression ) . fieldBinding ( ) ; } else if ( expression instanceof NameReference ) { Binding binding = ( ( NameReference ) expression ) . binding ; if ( binding != null && binding . kind ( ) == Binding . FIELD ) fieldBinding = ( FieldBinding ) binding ; } if ( fieldBinding != null && ( fieldBinding . modifiers & ClassFileConstants . AccEnum ) > 0 ) return fieldBinding ; } return null ; } public ElementValuePair ( char [ ] name , Expression expression , MethodBinding binding ) { this ( name , ElementValuePair . getValue ( expression ) , binding ) ; } public ElementValuePair ( char [ ] name , Object value , MethodBinding binding ) { this . name = name ; this . value = value ; this . binding = binding ; } public char [ ] getName ( ) { return this . name ; } public MethodBinding getMethodBinding ( ) { return this . binding ; } public Object getValue ( ) { return this . value ; } void setMethodBinding ( MethodBinding binding ) { this . binding = binding ; } void setValue ( Object value ) { this . value = value ; } public String toString ( ) { StringBuffer buffer = new StringBuffer ( 5 ) ; buffer . append ( this . name ) . append ( " = " ) ; buffer . append ( this . value ) ; return buffer . toString ( ) ; } } </s>