1 package de.matthias_burbach.mosaique.core.model;
2
3 import java.util.List;
4
5 /***
6 * Is the internal representation of a Tiles insert element defined on a JSP
7 * in order to insert/include a Tile.
8 *
9 * @author Matthias Burbach
10 */
11 public class Insert extends AbstractFileItem {
12 /***
13 * The attribute naming the alias of the definition to insert.
14 */
15 private String attribute;
16
17 /***
18 * The put attributes defined in the body of this insert element that add
19 * to the Tiles context when the definition is inserted.
20 */
21 private List puts;
22
23 /***
24 * @param context The context to use by this instance.
25 */
26 public Insert(final Context context) {
27 setContext(context);
28 }
29
30 /***
31 * @return The attribute naming the alias of the definition to insert.
32 */
33 public String getAttribute() {
34 return attribute;
35 }
36
37 /***
38 * @param attribute The attribute naming the alias of the definition to
39 * insert.
40 */
41 public void setAttribute(final String attribute) {
42 this.attribute = attribute;
43 }
44
45 /***
46 * @param tilesContext The Tiles context to evaluate the definition alias.
47 * @return The definition inserted by this insert element resolved from the
48 * definition's alias using the Tile's context passed in.
49 */
50 public Definition getDefinition(final TilesContext tilesContext) {
51 String definitionName = attribute;
52 if (tilesContext != null) {
53 String value = tilesContext.getValue(attribute);
54 if (value != null) {
55 definitionName = value;
56 }
57 }
58 return getDefinitionResolver().resolve(definitionName);
59 }
60
61 /***
62 * @return The put attributes defined in the body of this insert element
63 * that add to the Tiles context when the definition is inserted.
64 */
65 public List getPuts() {
66 return puts;
67 }
68
69 /***
70 * @param puts The put attributes defined in the body of this insert element
71 * that add to the Tiles context when the definition is
72 * inserted.
73 */
74 public void setPuts(final List puts) {
75 this.puts = puts;
76 }
77 }