001: /*
002: * Spoon - http://spoon.gforge.inria.fr/
003: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
004: *
005: * This software is governed by the CeCILL-C License under French law and
006: * abiding by the rules of distribution of free software. You can use, modify
007: * and/or redistribute the software under the terms of the CeCILL-C license as
008: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT
011: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
013: *
014: * The fact that you are presently reading this means that you have had
015: * knowledge of the CeCILL-C license and that you accept its terms.
016: */
017:
018: package spoon.processing;
019:
020: import java.util.Collection;
021:
022: import spoon.reflect.declaration.CtElement;
023:
024: /**
025: * The processing manager defines the API to process a program model of a given
026: * {@link spoon.reflect.Factory} with a set of processors. The program model has
027: * been previously built using a {@link spoon.processing.Builder} - see
028: * {@link spoon.processing.Builder#build()}. To use, add processors to
029: * the manager, and then call the {@code process} method. The processors will be
030: * removed from the manager once applied. Also, the method
031: * {@link spoon.processing.Processor#processingDone()} is upcalled.
032: *
033: * @see spoon.processing.Environment#getManager()
034: */
035: public interface ProcessingManager extends FactoryAccessor {
036: /**
037: * Adds a processor by instantiating its type (a class that must define an
038: * empty constructor).
039: *
040: * @see #getProcessors().
041: */
042: void addProcessor(Class<? extends Processor<?>> type);
043:
044: /**
045: * Adds a processor.
046: *
047: * @see #getProcessors().
048: */
049: boolean addProcessor(Processor<?> p);
050:
051: /**
052: * Adds a processor by instantiating its type (a class that must define an
053: * empty constructor and implement {@link Processor}).
054: *
055: * @param qualifiedName
056: * the qualified name of the processor's type
057: * @see #getProcessors().
058: */
059: void addProcessor(String qualifiedName);
060:
061: /**
062: * Returns {@code true} if the manager will apply a given processor type
063: * when invoking one of the {@code process} methods. To be applied
064: * processors are the ones that have been added with one of the
065: * {@code addProcessor} methods.
066: *
067: * @see #process(Collection)
068: * @see #process()
069: */
070: boolean isToBeApplied(Class<? extends Processor<?>> type);
071:
072: /**
073: * Gets the processors that have been added to the manager and that will be
074: * applied when invoking one of the {@code process} methods).
075: *
076: * @see #process(Collection)
077: * @see #process()
078: */
079: Collection<Processor<?>> getProcessors();
080:
081: /**
082: * Recursively processes a collection of {@link CtElement}s with this
083: * manager. All the processors added to this manager (see
084: * {@link #getProcessors()}) should be applied before the method returns
085: * (blocking implementation) or before another call to a
086: * <code>process</code> method (non-blocking implementation). Processors
087: * that have been applied are removed from the manager and
088: * {@link #getProcessors()} does not contain them anymore.
089: */
090: void process(Collection<? extends CtElement> elements);
091:
092: /**
093: * Recursively processes a {@link CtElement} with this manager. All the
094: * processors added to this manager (see {@link #getProcessors()}) should
095: * be applied before the method returns (blocking implementation) or before
096: * another call to a <code>process</code> method (non-blocking
097: * implementation). Processors that have been applied are removed from the
098: * manager and {@link #getProcessors()} does not contain them anymore.
099: */
100: void process(CtElement element);
101:
102: /**
103: * Processes the entire factory's model with this manager. All the
104: * processors added to this manager (see {@link #getProcessors()}) should
105: * be applied before the method returns (blocking implementation) or before
106: * another call to a <code>process</code> method (non-blocking
107: * implementation). Processors that have been applied are removed from the
108: * manager and {@link #getProcessors()} does not contain them anymore.
109: */
110: void process();
111:
112: /**
113: * Gets the processor which is currently achieving the processing task if
114: * any.
115: */
116: Processor<?> getCurrentProcessor();
117: }
|