View Javadoc

1   /*
2    * Copyright 2006 Outsource Cafe, Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the 'License')
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an 'AS IS' BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.javagen.agile.core.emitter;
17  
18  import org.javagen.agile.core.context.Context;
19  import org.javagen.agile.core.context.ContextHolder;
20  
21  /***
22   * An emitter is anything that emits code or data files.  
23   * <p>
24   * When the <code>emit</code> method is
25   * called by the framework, it is passed a context containing properties needed to generate an artifact.
26   * The emitter will typically bind the context to an associated template.  
27   * <p>
28   * The <code>artifact</code> property contains the location and name of the resulting
29   * generated file.  Artifacts are typically passed the same context handed to the template
30   * which allows the file name and path to be determined by the same properties that the 
31   * template uses.  
32   * <p>
33   * An emitter can also hold its own local context which can be used to customize it's behavior.
34   *
35   * @author Richard Easterling
36   */
37  public interface Emitter extends ContextHolder {
38  	
39      /***
40       * invoke an emitter 
41       * @param context - usually a composite of leaf, parent and template contexts.
42       */
43  	void emit(Context context);
44  	
45      /***
46       * The unique artifact instance that provides the file name and path to this emitter.  
47       * <p>WARNING: Artifact instances should not be shared between different emitters.
48       * @return the artifact associated with this emitter
49       */
50  	Artifact getArtifact();
51  
52  }