KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > magnet > domain > system > Variable


1 package org.sapia.magnet.domain.system;
2
3 // Import of Sapia's magnet classes
4
// --------------------------------
5
import org.sapia.magnet.render.AbstractRenderable;
6 import org.sapia.magnet.render.MagnetContext;
7 import org.sapia.magnet.render.RenderingException;
8
9
10 /**
11  *
12  * @author Jean-Cedric Desrochers
13  *
14  * <dl>
15  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
16  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
17  * <a HREF="http://www.sapia-oss.org/license.html" target="sapia-license">license page</a> at the Sapia OSS web site</dd></dt>
18  * </dl>
19  */

20 public class Variable extends AbstractRenderable {
21
22   /////////////////////////////////////////////////////////////////////////////////////////
23
///////////////////////////////// INSTANCE ATTRIBUTES /////////////////////////////////
24
/////////////////////////////////////////////////////////////////////////////////////////
25

26   /** The name of this variable. */
27   private String JavaDoc _theName;
28
29   /** The value of this variable. */
30   private String JavaDoc _theValue;
31
32   /////////////////////////////////////////////////////////////////////////////////////////
33
//////////////////////////////////// CONSTRUCTORS /////////////////////////////////////
34
/////////////////////////////////////////////////////////////////////////////////////////
35

36   /**
37    * Creates a new Variable instance.
38    */

39   public Variable() {
40   }
41
42   /////////////////////////////////////////////////////////////////////////////////////////
43
////////////////////////////////// ACCESSOR METHODS ///////////////////////////////////
44
/////////////////////////////////////////////////////////////////////////////////////////
45

46   /**
47    * Returns the name of this variable.
48    *
49    * @return The name of this variable.
50    */

51   public String JavaDoc getName() {
52     return _theName;
53   }
54
55   /**
56    * Returns the value of this variable.
57    *
58    * @return The value of this variable.
59    */

60   public String JavaDoc getValue() {
61     return _theValue;
62   }
63
64   /////////////////////////////////////////////////////////////////////////////////////////
65
/////////////////////////////////// MUTATOR METHODS ///////////////////////////////////
66
/////////////////////////////////////////////////////////////////////////////////////////
67

68   /**
69    * Changes the name of this variable.
70    *
71    * @param aName The new name.
72    */

73   public void setName(String JavaDoc aName) {
74     _theName = aName;
75   }
76
77   /**
78    * Changes the value of this variable.
79    *
80    * @param aValue The new value.
81    */

82   public void setValue(String JavaDoc aValue) {
83     _theValue = aValue;
84   }
85
86   /////////////////////////////////////////////////////////////////////////////////////////
87
////////////////////////////////// OVERRIDEN METHODS //////////////////////////////////
88
/////////////////////////////////////////////////////////////////////////////////////////
89

90   /**
91    * Renders this objects to the magnet context passed in.
92    *
93    * @param aContext The magnet context to use.
94    * @exception RenderingException If an error occurs while rendering this object.
95    */

96   public void render(MagnetContext aContext) throws RenderingException {
97     // Resolve the attributes
98
try {
99       _theName = resolveValue(aContext, _theName);
100       _theValue = resolveValue(aContext, _theValue);
101     } catch (RenderingException re) {
102       StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc();
103       aBuffer.append("Unable to resolve an attribute of the variable '").
104               append(_theName).append("'");
105       
106       throw new RenderingException(aBuffer.toString(), re);
107     }
108   }
109
110   /**
111    * Returns a string representation of this classpath.
112    *
113    * @return A string representation of this classpath.
114    */

115   public String JavaDoc toString() {
116     StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc(super.toString());
117     aBuffer.append("[name=").append(_theName).
118             append(" value=").append(_theValue).
119             append("]");
120
121     return aBuffer.toString();
122   }
123 }
124
Popular Tags