1 /**
2 * JSpiff
3 * -----------------
4 * Copyright (c) 2005-2006 Emil A. Lefkof III
5 *
6 * I always give it my best shot to make a program useful and solid, but
7 * remeber that there is absolutely no warranty for using this program as
8 * stated in the following terms:
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22 package com.melloware.jspiff.jaxp;
23
24 import java.io.IOException;
25 import java.io.PrintWriter;
26 import java.io.Writer;
27
28 import org.w3c.dom.Element;
29 import org.w3c.dom.Node;
30
31 /**
32 * <b>XspfAnythingAnyAttr</b> is generated from xspf.rng by Relaxer.
33 * This class is derived from:
34 *
35 * <!-- for programmer
36 * <attribute>
37 * <anyName/>
38 * </attribute>-->
39 * <!-- for javadoc -->
40 * <pre> <attribute>
41 * <anyName/>
42 * </attribute></pre>
43 *
44 * @version xspf.rng (Wed Sep 27 17:36:25 EDT 2006)
45 * @author Relaxer 1.1b (http://www.relaxer.org)
46 * @author Emil A. Lefkof III <info@melloware.com>
47 */
48 public class XspfAnythingAnyAttr
49 implements java.io.Serializable,
50 Cloneable,
51 IXspfAnythingMixed,
52 IXspfAnythingMixedChoice {
53
54 private static RNameClass $nameClass$ = new RNameClass("<anyName></anyName>");
55 private String $localName$ = "attribute";
56 private String content_;
57
58 /**
59 * Creates a <code>XspfAnythingAnyAttr</code>.
60 *
61 */
62 public XspfAnythingAnyAttr() {
63 }
64
65 /**
66 * Creates a <code>XspfAnythingAnyAttr</code>.
67 *
68 * @param source
69 */
70 public XspfAnythingAnyAttr(XspfAnythingAnyAttr source) {
71 setup(source);
72 }
73
74 /**
75 * Creates a <code>XspfAnythingAnyAttr</code> by the Stack <code>stack</code>
76 * that contains Elements.
77 * This constructor is supposed to be used internally
78 * by the Relaxer system.
79 *
80 * @param stack
81 */
82 public XspfAnythingAnyAttr(RStack stack) {
83 setup(stack);
84 }
85
86 /**
87 * Tests if elements contained in a Stack <code>stack</code>
88 * is valid for the <code>XspfAnythingAnyAttr</code>.
89 * This mehtod is supposed to be used internally
90 * by the Relaxer system.
91 *
92 * @param stack
93 * @return boolean
94 */
95 public static boolean isMatch(RStack stack) {
96 return (isMatchHungry(stack.makeClone()));
97 }
98
99 /**
100 * Tests if elements contained in a Stack <code>stack</code>
101 * is valid for the <code>XspfAnythingAnyAttr</code>.
102 * This method consumes the stack contents during matching operation.
103 * This mehtod is supposed to be used internally
104 * by the Relaxer system.
105 *
106 * @param stack
107 * @return boolean
108 */
109 public static boolean isMatchHungry(RStack stack) {
110 RStack target = stack;
111 boolean $match$ = false;
112 if (!$nameClass$.isMatchAttributeHungry(target)) {
113 return (false);
114 }
115 $match$ = true;
116 return ($match$);
117 }
118
119 /**
120 * Gets the String property <b>content</b>.
121 *
122 * @return String
123 */
124 public String getContent() {
125 return (content_);
126 }
127
128 /**
129 * Gets the property value as String.
130 *
131 * @return String
132 */
133 public String getContentAsString() {
134 return (URelaxer.getString(getContent()));
135 }
136
137 /**
138 * Sets the String property <b>content</b>.
139 *
140 * @param content
141 */
142 public void setContent(String content) {
143 this.content_ = content;
144 }
145
146 /**
147 * Sets the property value by String.
148 *
149 * @param string
150 */
151 public void setContentByString(String string) {
152 setContent(string);
153 }
154
155 /**
156 * @return Object
157 */
158 public Object clone() {
159 return (new XspfAnythingAnyAttr((XspfAnythingAnyAttr)this));
160 }
161
162 /**
163 * Creates a DOM representation of the object.
164 * Result is appended to the Node <code>parent</code>.
165 *
166 * @param parent
167 */
168 public void makeElement(Node parent) {
169 Element element = (Element)parent;
170 element.setAttribute($localName$, URelaxer.getString(getContent()));
171 }
172
173 /**
174 * Makes an XML text representation.
175 *
176 * @param buffer
177 */
178 public void makeTextAttribute(StringBuffer buffer) {
179 buffer.append(" ");
180 buffer.append($localName$);
181 buffer.append("=\"");
182 if (content_ != null) {
183 buffer.append(URelaxer.escapeCharData(URelaxer.getString(getContent())));
184 }
185 buffer.append("\"");
186 }
187
188 /**
189 * Makes an XML text representation.
190 *
191 * @param buffer
192 * @exception IOException
193 */
194 public void makeTextAttribute(Writer buffer)
195 throws IOException {
196 buffer.write(" ");
197 buffer.write($localName$);
198 buffer.write("=\"");
199 if (content_ != null) {
200 buffer.write(URelaxer.escapeCharData(URelaxer.getString(getContent())));
201 }
202 buffer.write("\"");
203 }
204
205 /**
206 * Makes an XML text representation.
207 *
208 * @param buffer
209 */
210 public void makeTextAttribute(PrintWriter buffer) {
211 buffer.print(" ");
212 buffer.print($localName$);
213 buffer.print("=\"");
214 if (content_ != null) {
215 buffer.print(URelaxer.escapeCharData(URelaxer.getString(getContent())));
216 }
217 buffer.print("\"");
218 }
219
220 /**
221 * Makes an XML text representation.
222 *
223 * @return String
224 */
225 public String makeTextDocument() {
226 StringBuffer buffer = new StringBuffer();
227 if (content_ != null) {
228 buffer.append(URelaxer.escapeCharData(URelaxer.getString(getContent())));
229 }
230 return (new String(buffer));
231 }
232
233 /**
234 * Makes an XML text representation.
235 *
236 * @param buffer
237 */
238 public void makeTextElement(StringBuffer buffer) {
239 }
240
241 /**
242 * Makes an XML text representation.
243 *
244 * @param buffer
245 * @exception IOException
246 */
247 public void makeTextElement(Writer buffer)
248 throws IOException {
249 }
250
251 /**
252 * Makes an XML text representation.
253 *
254 * @param buffer
255 */
256 public void makeTextElement(PrintWriter buffer) {
257 }
258
259 /**
260 * Initializes the <code>XspfAnythingAnyAttr</code> by the XspfAnythingAnyAttr <code>source</code>.
261 *
262 * @param source
263 */
264 public void setup(XspfAnythingAnyAttr source) {
265 content_ = source.content_;
266 }
267
268 /**
269 * Initializes the <code>XspfAnythingAnyAttr</code> by the Stack <code>stack</code>
270 * that contains Elements.
271 * This constructor is supposed to be used internally
272 * by the Relaxer system.
273 *
274 * @param stack
275 */
276 public void setup(RStack stack) {
277 String[] result = $nameClass$.getAttributeHungry(stack);
278 $localName$ = result[0];
279 String value = result[1];
280 setContent(value.toString());
281 }
282
283 /**
284 * Returns a String representation of this object.
285 * While this method informs as XML format representaion,
286 * it's purpose is just information, not making
287 * a rigid XML documentation.
288 *
289 * @return String
290 */
291 public String toString() {
292 try {
293 return (makeTextDocument());
294 } catch (Exception e) {
295 return (super.toString());
296 }
297 }
298 }