1 18 package org.apache.beehive.netui.compiler.typesystem.impl.env; 19 20 import org.apache.beehive.netui.compiler.typesystem.declaration.AnnotationTypeDeclaration; 21 import org.apache.beehive.netui.compiler.typesystem.declaration.Declaration; 22 import org.apache.beehive.netui.compiler.typesystem.declaration.TypeDeclaration; 23 import org.apache.beehive.netui.compiler.typesystem.env.AnnotationProcessorEnvironment; 24 import org.apache.beehive.netui.compiler.typesystem.env.Filer; 25 import org.apache.beehive.netui.compiler.typesystem.env.Messager; 26 import org.apache.beehive.netui.compiler.typesystem.impl.DelegatingImpl; 27 import org.apache.beehive.netui.compiler.typesystem.impl.WrapperFactory; 28 import org.apache.beehive.netui.compiler.typesystem.impl.declaration.AnnotationTypeDeclarationImpl; 29 import org.apache.beehive.netui.compiler.Diagnostics; 30 31 import java.util.Collection ; 32 import java.util.Map ; 33 import java.util.HashMap ; 34 35 public class AnnotationProcessorEnvironmentImpl 36 extends DelegatingImpl 37 implements AnnotationProcessorEnvironment 38 { 39 private TypeDeclaration[] _specifiedTypeDeclarations; 40 private Map _attributes; 41 private Diagnostics _diagnostics; 42 43 protected AnnotationProcessorEnvironmentImpl( com.sun.mirror.apt.AnnotationProcessorEnvironment delegate ) 44 { 45 super( delegate ); 46 } 47 48 public static AnnotationProcessorEnvironment get( com.sun.mirror.apt.AnnotationProcessorEnvironment delegate ) 49 { 50 return delegate != null ? new AnnotationProcessorEnvironmentImpl( delegate ) : null; 51 } 52 53 public Map getOptions() 54 { 55 return getDelegate().getOptions(); 56 } 57 58 public Messager getMessager() 59 { 60 return MessagerImpl.get( getDelegate().getMessager() ); 61 } 62 63 public Filer getFiler() 64 { 65 assert false : "NYI"; 66 throw new UnsupportedOperationException ( "not implemented" ); 67 } 68 69 public TypeDeclaration[] getSpecifiedTypeDeclarations() 70 { 71 if ( _specifiedTypeDeclarations == null ) 72 { 73 Collection <com.sun.mirror.declaration.TypeDeclaration> delegateCollection = getDelegate().getSpecifiedTypeDeclarations(); 74 TypeDeclaration[] array = new TypeDeclaration[delegateCollection.size()]; 75 int j = 0; 76 for ( com.sun.mirror.declaration.TypeDeclaration i : delegateCollection ) 77 { 78 array[j++] = WrapperFactory.get().getTypeDeclaration( i ); 79 } 80 _specifiedTypeDeclarations = array; 81 } 82 83 return _specifiedTypeDeclarations; 84 } 85 86 public TypeDeclaration getTypeDeclaration( String s ) 87 { 88 return WrapperFactory.get().getTypeDeclaration( getDelegate().getTypeDeclaration( s ) ); 89 } 90 91 public Declaration[] getDeclarationsAnnotatedWith( AnnotationTypeDeclaration decl ) 92 { 93 assert decl instanceof AnnotationTypeDeclarationImpl : decl.getClass().getName(); 94 Collection < com.sun.mirror.declaration.Declaration > delegateCollection = 95 getDelegate().getDeclarationsAnnotatedWith( ( ( AnnotationTypeDeclarationImpl ) decl ).getDelegate() ); 96 Declaration[] array = new Declaration[ delegateCollection.size() ]; 97 int j = 0; 98 for ( com.sun.mirror.declaration.Declaration i : delegateCollection ) 99 { 100 array[ j++ ] = WrapperFactory.get().getDeclaration( i ); 101 } 102 return array; 103 } 104 105 protected com.sun.mirror.apt.AnnotationProcessorEnvironment getDelegate() 106 { 107 return ( com.sun.mirror.apt.AnnotationProcessorEnvironment ) super.getDelegate(); 108 } 109 110 public void setAttribute( String propertyName, Object value ) 111 { 112 if ( _attributes == null ) _attributes = new HashMap (); 113 _attributes.put( propertyName, value ); 114 } 115 116 public Object getAttribute( String propertyName ) 117 { 118 return _attributes != null ? _attributes.get( propertyName ) : null; 119 } 120 } 121 | Popular Tags |