01: /*
02: * Spoon - http://spoon.gforge.inria.fr/
03: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
04: *
05: * This software is governed by the CeCILL-C License under French law and
06: * abiding by the rules of distribution of free software. You can use, modify
07: * and/or redistribute the software under the terms of the CeCILL-C license as
08: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
13: *
14: * The fact that you are presently reading this means that you have had
15: * knowledge of the CeCILL-C license and that you accept its terms.
16: */
17:
18: package spoon.template;
19:
20: import spoon.reflect.declaration.CtType;
21:
22: /**
23: * This maker interface should be implemented by the classes containing some
24: * template code, so that they can be used as template parameter values holder
25: * for the {@link Substitution} methods.
26: *
27: * <p>
28: * A template code is simply a piece of code that uses a
29: * {@link TemplateParameter}'s instance. It must then invoke the
30: * {@link TemplateParameter#S()} method.
31: *
32: * <p>
33: * When the template parameter is a String or a primitive type (or a boxing
34: * type) representing a literal, or a Class, the template parameter can be
35: * directly accessed.
36: *
37: * <pre>
38: * import spoon.template.Template;
39: * import spoon.template.Value;
40: *
41: * public class SimpleTemplate implements Template {
42: * // template parameter fields
43: * \@Parameter String _parameter_;
44: *
45: * // parameters binding
46: * \@Local
47: * public SimpleTemplate(String parameter) {
48: * _parameter_ = parameter;
49: * }
50: *
51: * // template method
52: * public void simpleTemplateMethod() {
53: * System.out.println(_parameter_);
54: * }
55: * }
56: * </pre>
57: *
58: * <p>
59: * The template parameters must be bound to their values in the template's
60: * constructor (which should be defined as a template's
61: * {@link spoon.template.Local}. A possible use of a template would be to
62: * insert the template into a target class, by using
63: * {@link Substitution#insertAll(CtType,Template)}:
64: *
65: * <pre>
66: * spoon.reflect.CtClass target=...;
67: * Template template=new SimpleTemplate("hello templated world");
68: * Substitution.insertAll(target,template);
69: * </pre>
70: *
71: * <p>
72: * If the target class is an empty class named <code>A</code>, the resulting
73: * code will be:
74: *
75: * <pre>
76: * public class A {
77: * public void insertedMethod() {
78: * System.out.println("hello templated world");
79: * }
80: * }
81: * </pre>
82: *
83: */
84: public interface Template {
85: }
|