1 18 package org.apache.beehive.netui.compiler.xdoclet.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.xdoclet.typesystem.impl.DelegatingImpl; 27 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.WrapperFactory; 28 import org.apache.beehive.netui.compiler.xdoclet.typesystem.impl.declaration.AnnotationTypeDeclarationImpl; 29 import org.apache.beehive.netui.xdoclet.NetuiSubTask; 30 import org.apache.beehive.netui.xdoclet.XDocletCompilerUtils; 31 import xdoclet.DocletContext; 32 import xjavadoc.SourceClass; 33 import xjavadoc.XDoc; 34 import xjavadoc.XJavaDoc; 35 36 import java.util.Map ; 37 import java.util.HashMap ; 38 39 public class AnnotationProcessorEnvironmentImpl 40 extends DelegatingImpl 41 implements AnnotationProcessorEnvironment 42 { 43 private static final Declaration[] EMPTY_DECLARATION_ARRAY = new Declaration[0]; 44 45 private NetuiSubTask _subtask; 46 private SourceClass _sourceClass; 47 private HashMap _attributes; 48 49 protected AnnotationProcessorEnvironmentImpl( DocletContext delegate, NetuiSubTask subtask, SourceClass sourceClass ) 50 { 51 super( delegate ); 52 _subtask = subtask; 53 _sourceClass = sourceClass; 54 } 55 56 public static AnnotationProcessorEnvironment get( DocletContext delegate, NetuiSubTask subtask, SourceClass sc ) 57 { 58 return delegate != null ? new AnnotationProcessorEnvironmentImpl( delegate, subtask, sc ) : null; 59 } 60 61 public Map getOptions() 62 { 63 return getDelegateDocletContext().getProperties(); 64 } 65 66 public Messager getMessager() 67 { 68 return new MessagerImpl( _sourceClass ); 69 } 70 71 public Filer getFiler() 72 { 73 assert false : "NYI"; 74 throw new UnsupportedOperationException ( "not implemented" ); 75 } 76 77 public TypeDeclaration[] getSpecifiedTypeDeclarations() 78 { 79 94 assert false : "NYI"; 95 throw new UnsupportedOperationException ( "NYI" ); 96 } 97 98 public TypeDeclaration getTypeDeclaration( String s ) 99 { 100 return XDocletCompilerUtils.resolveTypeDeclaration( s ); 101 } 102 103 public Declaration[] getDeclarationsAnnotatedWith( AnnotationTypeDeclaration decl ) 104 { 105 XDoc doc = _sourceClass.getDoc(); 109 110 if ( doc != null ) 111 { 112 assert decl instanceof AnnotationTypeDeclarationImpl : decl.getClass().getName(); 113 if ( doc.getTag( ( ( AnnotationTypeDeclarationImpl ) decl ).getIntermediateName() ) != null ) 114 { 115 return new Declaration[]{ WrapperFactory.get().getTypeDeclaration( _sourceClass ) }; 116 } 117 } 118 119 return EMPTY_DECLARATION_ARRAY; 120 } 121 122 public DocletContext getDelegateDocletContext() 123 { 124 return ( DocletContext ) super.getDelegate(); 125 } 126 127 protected final XJavaDoc getXJavaDoc() 128 { 129 return _subtask.getXJavaDoc(); 130 } 131 132 public void setAttribute( String propertyName, Object value ) 133 { 134 if ( _attributes == null ) _attributes = new HashMap (); 135 _attributes.put( propertyName, value ); 136 } 137 138 public Object getAttribute( String propertyName ) 139 { 140 return _attributes != null ? _attributes.get( propertyName ) : null; 141 } 142 } 143 | Popular Tags |