KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > helpers > InnerString


1 /**
2  * $Id: InnerString.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2004 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or (at your option) any
9  * later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.helpers;
30
31 import org.apache.tools.ant.Project;
32
33 /**
34  * Brain-dead luggage String bean (ha-ha) that allows nested &lt;defaultmsg&gt; elements
35  * and other simple "string holder" elements. The string's contents should be specified
36  * as either a single 'value' attribute or as nested text.
37  *
38  * @since JWare/AntX 0.1
39  * @author ssmc, &copy;2002-2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
40  * @version 0.5
41  * @.safety single
42  * @.group impl,helper
43  **/

44
45 public final class InnerString
46 {
47     /**
48      * Creates new empty string.
49      **/

50     public InnerString()
51     {
52     }
53
54
55     /**
56      * Creates new predefined string.
57      **/

58     public InnerString(String JavaDoc it)
59     {
60         addText(it);
61     }
62
63
64     /**
65      * <em>Replaces</em> this string's current text.
66      * @param s the new text (non-null)
67      * @since JWare/AntX 0.2
68      **/

69     public void setValue(String JavaDoc s)
70     {
71         m_It = s;
72     }
73
74
75     /**
76      * Adds more text to this string.
77      **/

78     public void addText(String JavaDoc it)
79     {
80         m_It += it;
81     }
82
83
84     /**
85      * Synonymn for {@linkplain #setValue setValue} that is
86      * semantically more appropriate for some uses of this class.
87      * @param s the new text (non-null)
88      * @since JWare/AntX 0.2
89      **/

90     public void setName(String JavaDoc s)
91     {
92         setValue(s);
93     }
94
95
96     /**
97      * Returns this string's current text.
98      **/

99     public String JavaDoc getText()
100     {
101         return m_It;
102     }
103
104
105     /**
106      * Same as {@linkplain #getText getText()}.
107      **/

108     public String JavaDoc toString()
109     {
110         return getText();
111     }
112
113
114     /**
115      * Same as {@linkplain #getText getText()} but with
116      * embedded properties replaced with project definitions.
117      * @param P project from which properties resolved
118      **/

119     public String JavaDoc toString(final Project P)
120     {
121         String JavaDoc s = getText();
122         return (P!=null) ? Tk.resolveString(P,s) : s;
123     }
124
125
126     private String JavaDoc m_It="";
127 }
128
129 /* end-of-InnerString.java */
130
Popular Tags