001: /*
002: * @(#)AnnotationProcessorFactory.java 1.9 04/07/13
003: *
004: * Copyright (c) 2004, Sun Microsystems, Inc.
005: * All rights reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions are met:
009: *
010: * * Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: * * Neither the name of the Sun Microsystems, Inc. nor the names of
016: * its contributors may be used to endorse or promote products derived from
017: * this software without specific prior written permission.
018: *
019: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
020: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
021: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
022: * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
023: * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
024: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
025: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
026: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
027: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
028: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
029: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: */
031:
032: package com.sun.mirror.apt;
033:
034: import java.util.Collection;
035: import java.util.Set;
036:
037: import com.sun.mirror.declaration.AnnotationTypeDeclaration;
038:
039: /**
040: * A factory for creating annotation processors.
041: * Each factory is responsible for creating processors for one or more
042: * annotation types.
043: * The factory is said to <i>support</i> these types.
044: *
045: * <p> Each implementation of an <tt>AnnotationProcessorFactory</tt>
046: * must provide a public no-argument constructor to be used by tools to
047: * instantiate the factory.
048: *
049: * @author Joseph D. Darcy
050: * @author Scott Seligman
051: * @version 1.9 04/07/13
052: * @since 1.5
053: */
054:
055: public interface AnnotationProcessorFactory {
056:
057: /**
058: * Returns the options recognized by this factory or by any of the
059: * processors it may create.
060: * Only {@linkplain AnnotationProcessorEnvironment#getOptions()
061: * processor-specific} options are included, each of which begins
062: * with <tt>"-A"</tt>. For example, if this factory recognizes
063: * options such as <tt>-Adebug -Aloglevel=3</tt>, it will
064: * return the strings <tt>"-Adebug"</tt> and <tt>"-Aloglevel"</tt>.
065: *
066: * <p> A tool might use this information to determine if any
067: * options provided by a user are unrecognized by any processor,
068: * in which case it may wish to report an error.
069: *
070: * @return the options recognized by this factory or by any of the
071: * processors it may create, or an empty collection if none
072: */
073: Collection<String> supportedOptions();
074:
075: /**
076: * Returns the names of the annotation types supported by this factory.
077: * An element of the result may be the canonical (fully qualified) name
078: * of a supported annotation type. Alternately it may be of the form
079: * <tt>"<i>name</i>.*"</tt>
080: * representing the set of all annotation types
081: * with canonical names beginning with <tt>"<i>name</i>."</tt>
082: * Finally, <tt>"*"</tt> by itself represents the set of all
083: * annotation types.
084: *
085: * @return the names of the annotation types supported by this factory
086: */
087: Collection<String> supportedAnnotationTypes();
088:
089: /**
090: * Returns an annotation processor for a set of annotation
091: * types. The set will be empty if the factory supports
092: * "<tt>*</tt>" and the specified type declarations have
093: * no annotations. Note that the set of annotation types may be
094: * empty for other reasons, such as giving the factory an
095: * opportunity to register a listener. An
096: * <tt>AnnotationProcessorFactory</tt> must gracefully handle an
097: * empty set of annotations; an appropriate response to an empty
098: * set will often be returning {@link AnnotationProcessors#NO_OP}.
099: *
100: * @param atds type declarations of the annotation types to be processed
101: * @param env environment to use during processing
102: * @return an annotation processor for the given annotation types,
103: * or <tt>null</tt> if the types are not supported or the
104: * processor cannot be created
105: */
106: AnnotationProcessor getProcessorFor(
107: Set<AnnotationTypeDeclaration> atds,
108: AnnotationProcessorEnvironment env);
109: }
|