1 18 package org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.declaration; 19 20 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationValue; 21 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeElementDeclaration; 22 import org.apache.beehive.netui.compiler.typesystem.util.SourcePosition; 23 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.DelegatingImpl; 24 import org.apache.beehive.netui.xdoclet.XDocletCompilerUtils; 25 26 import java.util.Iterator ; 27 28 public class AnnotationValueImpl 29 extends DelegatingImpl 30 implements AnnotationValue 31 { 32 private SourcePosition _position; 33 34 public AnnotationValueImpl( Object value, SourcePosition position, AnnotationTypeElementDeclaration decl ) 35 { 36 super( value ); 37 _position = position; 38 39 if ( decl != null ) 40 { 41 assert decl instanceof AnnotationTypeElementDeclarationImpl : decl.getClass().getName(); 42 AnnotationTypeElementDeclarationImpl declImpl = ( AnnotationTypeElementDeclarationImpl ) decl; 43 44 if ( ! declImpl.isValidValue( value ) ) 45 { 46 StringBuffer values = new StringBuffer (); 47 for ( Iterator i = declImpl.getValidValues().iterator(); i.hasNext(); ) 48 { 49 String validValue = ( String ) i.next(); 50 values.append( ' ' ).append( validValue ); 51 } 52 53 XDocletCompilerUtils.addError( position, "error.invalid-enum-value", 54 new String []{ value.toString(), decl.getSimpleName(), values.toString() } ); 55 } 56 } 57 } 58 59 public Object getValue() 60 { 61 return getDelegate(); 62 } 63 64 public SourcePosition getPosition() 65 { 66 return _position; 67 } 68 69 public boolean equals( Object o ) 70 { 71 return this == o; 72 } 73 } 74 | Popular Tags |