KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > magnet > domain > Profile


1 package org.sapia.magnet.domain;
2
3 // Import of Sapia's magnet classes
4
// --------------------------------
5
import org.sapia.magnet.render.MagnetContext;
6 import org.sapia.magnet.render.RenderingException;
7
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 Profile extends AbstractObjectHandler {
21     
22     static Parameters EMPTY_PARAMETERS = new Parameters();
23
24   /////////////////////////////////////////////////////////////////////////////////////////
25
///////////////////////////////// INSTANCE ATTRIBUTES /////////////////////////////////
26
/////////////////////////////////////////////////////////////////////////////////////////
27

28   /** The name of this profile. */
29   private String JavaDoc _theName;
30
31   /** The parameters of this profile. */
32   private Parameters _theParameters = EMPTY_PARAMETERS;
33
34   /////////////////////////////////////////////////////////////////////////////////////////
35
//////////////////////////////////// CONSTRUCTORS /////////////////////////////////////
36
/////////////////////////////////////////////////////////////////////////////////////////
37

38   /**
39    * Creates a new Profile instance.
40    */

41   public Profile() {
42   }
43
44   /////////////////////////////////////////////////////////////////////////////////////////
45
////////////////////////////////// ACCESSOR METHODS ///////////////////////////////////
46
/////////////////////////////////////////////////////////////////////////////////////////
47

48   /**
49    * Returns the name of this profile.
50    *
51    * @return The name of this profile.
52    */

53   public String JavaDoc getName() {
54     return _theName;
55   }
56
57   /**
58    * Returns the parameters of this profile.
59    *
60    * @return The parameters of this profile.
61    */

62   public Parameters getParameters() {
63     return _theParameters;
64   }
65
66   /////////////////////////////////////////////////////////////////////////////////////////
67
/////////////////////////////////// MUTATOR METHODS ///////////////////////////////////
68
/////////////////////////////////////////////////////////////////////////////////////////
69

70   /**
71    * Changes the name of this profile to the one passed in.
72    *
73    * @param aName The new name of this profile.
74    */

75   public void setName(String JavaDoc aName) {
76     _theName = aName;
77   }
78
79   /**
80    * Changes the parameters of this profile to the one passed in.
81    *
82    * @param aParameters The new parameters of this profile.
83    */

84   public void setParameters(Parameters aParameters) {
85     _theParameters = aParameters;
86   }
87
88   /////////////////////////////////////////////////////////////////////////////////////////
89
////////////////////////////////// OVERRIDEN METHODS //////////////////////////////////
90
/////////////////////////////////////////////////////////////////////////////////////////
91

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

98   public void render(MagnetContext aContext) throws RenderingException {
99     MagnetContext aSubContext = new MagnetContext(aContext);
100
101     // Render the parameters of this profile, if any
102
try {
103       if (_theParameters != null) {
104         _theParameters.render(aSubContext);
105       }
106     } catch (RenderingException re) {
107       StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc();
108       aBuffer.append("Unable to render the parameters of the profile ").
109               append(_theName);
110       throw new RenderingException(aBuffer.toString(), re);
111     }
112
113     // Render the handler definitions
114
try {
115       super.renderHandlerDefs(aContext);
116     } catch (RenderingException re) {
117       StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc();
118       aBuffer.append("Unable to render the handler defs of the profile ").
119               append(_theName);
120       throw new RenderingException(aBuffer.toString(), re);
121     }
122
123     // Render all the objects handled by this profile
124
try {
125       super.render(aSubContext);
126     } catch (RenderingException re) {
127       StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc();
128       aBuffer.append("Unable to render an object of the profile ").
129               append(_theName);
130       throw new RenderingException(aBuffer.toString(), re);
131     }
132   }
133
134   /**
135    * Returns a string representation of this profile.
136    *
137    * @return A string representation of this profile.
138    */

139   public String JavaDoc toString() {
140     StringBuffer JavaDoc aBuffer = new StringBuffer JavaDoc(super.toString());
141     aBuffer.append("[name=").append(_theName).
142             append(" parameters=").append(_theParameters).
143             append("]");
144
145     return aBuffer.toString();
146   }
147 }
148
Popular Tags