1 package org.sapia.magnet.domain; 2 3 import org.sapia.magnet.render.AbstractRenderable; 6 import org.sapia.magnet.render.MagnetContext; 7 import org.sapia.magnet.render.RenderingException; 8 9 10 21 public class Param extends AbstractRenderable { 22 23 27 28 public static final String SCOPE_SYSTEM = "system"; 29 30 31 public static final String SCOPE_MAGNET = "magnet"; 32 33 37 38 private String _theName; 39 40 41 private String _theValue; 42 43 44 private String _theScope; 45 46 47 private String _theIfDefine; 48 49 50 private String _theUnlessDefine; 51 52 56 59 public Param() { 60 _theScope = SCOPE_MAGNET; 61 } 62 63 69 public Param(String aName, String aValue) { 70 this(aName, aValue, SCOPE_MAGNET); 71 } 72 73 80 public Param(String aName, String aValue, String aScope) { 81 _theName = aName; 82 _theValue = aValue; 83 _theScope = aScope; 84 } 85 86 90 95 public String getName() { 96 return _theName; 97 } 98 99 104 public String getValue() { 105 return _theValue; 106 } 107 108 113 public String getScope() { 114 return _theScope; 115 } 116 117 124 public String getIfDefine() { 125 return _theIfDefine; 126 } 127 128 135 public String getUnlessDefine() { 136 return _theUnlessDefine; 137 } 138 139 140 141 145 150 public void setName(String aName) { 151 _theName = aName; 152 } 153 154 159 public void setValue(String aValue) { 160 _theValue = aValue; 161 } 162 163 168 public void setScope(String aScope) { 169 _theScope = aScope; 170 } 171 172 178 public void setIfDefine(String aParamName) { 179 _theIfDefine = aParamName; 180 } 181 182 188 public void setUnlessDefine(String aParamName) { 189 _theUnlessDefine = aParamName; 190 } 191 192 196 202 public void render(MagnetContext aContext) throws RenderingException { 203 try { 204 _theValue = resolveValue(aContext, _theValue); 205 _theScope = resolveValue(aContext, _theScope); 206 } catch (RenderingException re) { 207 StringBuffer aBuffer = new StringBuffer (); 208 aBuffer.append("Unable to resolve an attribute of the param '"). 209 append(_theName).append("'"); 210 211 throw new RenderingException(aBuffer.toString(), re); 212 } 213 } 214 215 220 public String toString() { 221 StringBuffer aBuffer = new StringBuffer (super.toString()); 222 aBuffer.append("[name=").append(_theName). 223 append(" value=").append(_theValue). 224 append(" scope=").append(_theScope). 225 append(" ifDefine=").append(_theIfDefine). 226 append(" unlessDefine=").append(_theUnlessDefine). 227 append("]"); 228 229 return aBuffer.toString(); 230 } 231 } 232 | Popular Tags |