KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > util > text > ConstantElement


1 package org.sapia.util.text;
2
3
4 /**
5  * A template element holding non-variable data.
6  *
7  * @author JC Desrochers
8  *
9  * <dl>
10  * <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>
11  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
12  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
13  * </dl>
14  */

15 public class ConstantElement implements TemplateElementIF {
16   /////////////////////////////////////////////////////////////////////////////////////////
17
///////////////////////////////// INSTANCE ATTRIBUTES /////////////////////////////////
18
/////////////////////////////////////////////////////////////////////////////////////////
19

20   /** The content of this constant element. */
21   private String JavaDoc _theContent;
22
23   /////////////////////////////////////////////////////////////////////////////////////////
24
//////////////////////////////////// CONSTRUCTORS /////////////////////////////////////
25
/////////////////////////////////////////////////////////////////////////////////////////
26

27   /**
28    * Creates a new ConstantElement instance with the content passed in.
29    *
30    * @param aContent The content of this constant element.
31    */

32   public ConstantElement(String JavaDoc aContent) {
33     _theContent = aContent;
34   }
35
36   /////////////////////////////////////////////////////////////////////////////////////////
37
////////////////////////////////// ACCESSOR METHODS ///////////////////////////////////
38
/////////////////////////////////////////////////////////////////////////////////////////
39

40   /**
41    * Returns the content of this constant element.
42    *
43    * @return The content of this constant element.
44    */

45   public String JavaDoc getContent() {
46     return _theContent;
47   }
48
49   /////////////////////////////////////////////////////////////////////////////////////////
50
/////////////////////////////// INTERACE IMPLEMENTATION ///////////////////////////////
51
/////////////////////////////////////////////////////////////////////////////////////////
52

53   /**
54    * Renders this template element using the template context passed in and
55    * returns the result in a new string.
56    *
57    * @param aContext The template context to use in the rendering process.
58    * @return The result of the rendering operation as a new string.
59    * @exception TemplateException If an error occurs rendering this template element.
60    */

61   public String JavaDoc render(TemplateContextIF aContext) throws TemplateException {
62     return _theContent;
63   }
64
65   /**
66    * Renders this template element using the template context passed in and
67    * appending the result in the string buffer passed in.
68    *
69    * @param aContext The template context to use in the rendering process.
70    * @exception TemplateException If an error occurs rendering this template element.
71    */

72   public void render(TemplateContextIF aContext, StringBuffer JavaDoc aBuffer)
73     throws TemplateException {
74     aBuffer.append(_theContent);
75   }
76 }
77
Popular Tags