1 package de.matthias_burbach.mosaique.core.model; 2 3 /*** 4 * Is the internal representation of a Tiles put element that occurs within 5 * a Tiles definition or a Tiles insert element. 6 * 7 * @author Matthias Burbach 8 */ 9 public class Put extends AbstractFileItem { 10 /*** 11 * The name of the attribute. 12 */ 13 private String name; 14 15 /*** 16 * The value of the attribute. 17 */ 18 private String value; 19 20 /*** 21 * The definition putting this attribute. Is <code>null</code> if this is 22 * a dynamic put on a JSP within a tiles:insert element. 23 */ 24 private Definition owner; 25 26 /*** 27 * Is <code>true</code> if this put is defined on a JSP within a 28 * tiles:insert element. The default is <code>false</code>. 29 */ 30 private boolean dynamicPut = false; 31 32 /*** 33 * @param context The context to use by this instance. 34 */ 35 public Put(final Context context) { 36 setContext(context); 37 } 38 39 /*** 40 * @return The definition putting this attribute. Is <code>null</code> if 41 * this is a dynamic put on a JSP within a tiles:insert element. 42 */ 43 public Definition getOwner() { 44 return owner; 45 } 46 47 /*** 48 * @param owner The definition putting this attribute. Is <code>null</code> 49 * if this is a dynamic put on a JSP within a tiles:insert 50 * element. 51 */ 52 public void setOwner(final Definition owner) { 53 this.owner = owner; 54 } 55 56 /*** 57 * @return The definition referenced by the attributes value. Is 58 * <code>null</code> if the value is not the name of a Tiles 59 * definition. 60 */ 61 public Definition getReferencedDefinition() { 62 return getDefinitionResolver().resolve(value); 63 } 64 65 /*** 66 * @return The name of the attribute. 67 */ 68 public String getName() { 69 return name; 70 } 71 72 /*** 73 * @param name The name of the attribute. 74 */ 75 public void setName(final String name) { 76 this.name = name; 77 } 78 79 /*** 80 * @return The value of the attribute. 81 */ 82 public String getValue() { 83 return value; 84 } 85 86 /*** 87 * @param value The value of the attribute. 88 */ 89 public void setValue(final String value) { 90 this.value = value; 91 } 92 93 /*** 94 * @return The level of the owner definition or -1 if there is no owner. 95 * See {@link Definition#getLevel()}. 96 */ 97 public int getLevel() { 98 int result = -1; 99 if (owner != null) { 100 result = owner.getLevel(); 101 } 102 return result; 103 } 104 105 /*** 106 * @return Is <code>true</code> if this put is defined on a JSP within a 107 * tiles:insert element. The default is <code>false</code>. 108 */ 109 public boolean isDynamicPut() { 110 return dynamicPut; 111 } 112 113 /*** 114 * @param dynamicPut Is <code>true</code> if this put is defined on a JSP 115 * within a tiles:insert element. 116 * The default is <code>false</code>. 117 */ 118 public void setDynamicPut(final boolean dynamicPut) { 119 this.dynamicPut = dynamicPut; 120 } 121 }