KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > templates > DecimalFormatProperties


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: DecimalFormatProperties.java,v 1.15 2004/02/16 20:32:32 minchau Exp $
18  */

19 package org.apache.xalan.templates;
20
21 import java.text.DecimalFormatSymbols JavaDoc;
22
23 import org.apache.xml.utils.QName;
24
25 /**
26  * Implement xsl:decimal-format.
27  * <pre>
28  * <!ELEMENT xsl:decimal-format EMPTY>
29  * <!ATTLIST xsl:decimal-format
30  * name %qname; #IMPLIED
31  * decimal-separator %char; "."
32  * grouping-separator %char; ","
33  * infinity CDATA "Infinity"
34  * minus-sign %char; "-"
35  * NaN CDATA "NaN"
36  * percent %char; "%"
37  * per-mille %char; "&#x2030;"
38  * zero-digit %char; "0"
39  * digit %char; "#"
40  * pattern-separator %char; ";"
41  * >
42  * </pre>
43  * @see <a HREF="http://www.w3.org/TR/xslt#format-number">format-number in XSLT Specification</a>
44  * @xsl.usage advanced
45  */

46 public class DecimalFormatProperties extends ElemTemplateElement
47 {
48
49   /** An instance of DecimalFormatSymbols for this element.
50    * @serial */

51   DecimalFormatSymbols JavaDoc m_dfs;
52
53   /**
54    * Constructor DecimalFormatProperties
55    *
56    */

57   public DecimalFormatProperties(int docOrderNumber)
58   {
59
60     m_dfs = new java.text.DecimalFormatSymbols JavaDoc();
61
62     // Set default values, they can be overiden if necessary.
63
m_dfs.setInfinity(Constants.ATTRVAL_INFINITY);
64     m_dfs.setNaN(Constants.ATTRVAL_NAN);
65
66     m_docOrderNumber = docOrderNumber;
67   }
68
69   /**
70    * Return the decimal format Symbols for this element.
71    * <p>The xsl:decimal-format element declares a decimal-format,
72    * which controls the interpretation of a format pattern used by
73    * the format-number function. If there is a name attribute, then
74    * the element declares a named decimal-format; otherwise, it
75    * declares the default decimal-format. The value of the name
76    * attribute is a QName, which is expanded as described in [2.4 Qualified Names].
77    * It is an error to declare either the default decimal-format or a
78    * decimal-format with a given name more than once (even with different
79    * import precedence), unless it is declared every time with the same
80    * value for all attributes (taking into account any default values).</p>
81    * <p>The other attributes on xsl:decimal-format correspond to the
82    * methods on the JDK 1.1 DecimalFormatSymbols class. For each get/set
83    * method pair there is an attribute defined for the xsl:decimal-format
84    * element.</p>
85    *
86    * @return the decimal format Symbols for this element.
87    */

88   public DecimalFormatSymbols JavaDoc getDecimalFormatSymbols()
89   {
90     return m_dfs;
91   }
92
93   /**
94    * If there is a name attribute, then the element declares a named
95    * decimal-format; otherwise, it declares the default decimal-format.
96    * @serial
97    */

98   private QName m_qname = null;
99
100   /**
101    * Set the "name" attribute.
102    * If there is a name attribute, then the element declares a named
103    * decimal-format; otherwise, it declares the default decimal-format.
104    *
105    * @param qname The name to set as the "name" attribute.
106    */

107   public void setName(QName qname)
108   {
109     m_qname = qname;
110   }
111
112   /**
113    * Get the "name" attribute.
114    * If there is a name attribute, then the element declares a named
115    * decimal-format; otherwise, it declares the default decimal-format.
116    *
117    * @return the value of the "name" attribute.
118    */

119   public QName getName()
120   {
121
122     if (m_qname == null)
123       return new QName("");
124     else
125       return m_qname;
126   }
127
128   /**
129    * Set the "decimal-separator" attribute.
130    * decimal-separator specifies the character used for the decimal sign;
131    * the default value is the period character (.).
132    *
133    * @param ds Character to set as decimal separator
134    */

135   public void setDecimalSeparator(char ds)
136   {
137     m_dfs.setDecimalSeparator(ds);
138   }
139
140   /**
141    * Get the "decimal-separator" attribute.
142    * decimal-separator specifies the character used for the decimal sign;
143    * the default value is the period character (.).
144    *
145    * @return the character to use as decimal separator
146    */

147   public char getDecimalSeparator()
148   {
149     return m_dfs.getDecimalSeparator();
150   }
151
152   /**
153    * Set the "grouping-separator" attribute.
154    * grouping-separator specifies the character used as a grouping
155    * (e.g. thousands) separator; the default value is the comma character (,).
156    *
157    * @param gs Character to use a grouping separator
158    */

159   public void setGroupingSeparator(char gs)
160   {
161     m_dfs.setGroupingSeparator(gs);
162   }
163
164   /**
165    * Get the "grouping-separator" attribute.
166    * grouping-separator specifies the character used as a grouping
167    * (e.g. thousands) separator; the default value is the comma character (,).
168    *
169    * @return Character to use a grouping separator
170    */

171   public char getGroupingSeparator()
172   {
173     return m_dfs.getGroupingSeparator();
174   }
175
176   /**
177    * Set the "infinity" attribute.
178    * infinity specifies the string used to represent infinity;
179    * the default value is the string Infinity.
180    *
181    * @param inf String to use as the "infinity" attribute.
182    */

183   public void setInfinity(String JavaDoc inf)
184   {
185     m_dfs.setInfinity(inf);
186   }
187
188   /**
189    * Get the "infinity" attribute.
190    * infinity specifies the string used to represent infinity;
191    * the default value is the string Infinity.
192    *
193    * @return String to use as the "infinity" attribute.
194    */

195   public String JavaDoc getInfinity()
196   {
197     return m_dfs.getInfinity();
198   }
199
200   /**
201    * Set the "minus-sign" attribute.
202    * minus-sign specifies the character used as the default minus sign; the
203    * default value is the hyphen-minus character (-, #x2D).
204    *
205    * @param v Character to use as minus sign
206    */

207   public void setMinusSign(char v)
208   {
209     m_dfs.setMinusSign(v);
210   }
211
212   /**
213    * Get the "minus-sign" attribute.
214    * minus-sign specifies the character used as the default minus sign; the
215    * default value is the hyphen-minus character (-, #x2D).
216    *
217    * @return Character to use as minus sign
218    */

219   public char getMinusSign()
220   {
221     return m_dfs.getMinusSign();
222   }
223
224   /**
225    * Set the "NaN" attribute.
226    * NaN specifies the string used to represent the NaN value;
227    * the default value is the string NaN.
228    *
229    * @param v String to use as the "NaN" attribute.
230    */

231   public void setNaN(String JavaDoc v)
232   {
233     m_dfs.setNaN(v);
234   }
235
236   /**
237    * Get the "NaN" attribute.
238    * NaN specifies the string used to represent the NaN value;
239    * the default value is the string NaN.
240    *
241    * @return String to use as the "NaN" attribute.
242    */

243   public String JavaDoc getNaN()
244   {
245     return m_dfs.getNaN();
246   }
247   
248   /**
249    * Return the node name.
250    *
251    * @return the element's name
252    */

253   public String JavaDoc getNodeName()
254   {
255     return Constants.ELEMNAME_DECIMALFORMAT_STRING;
256   }
257
258   /**
259    * Set the "percent" attribute.
260    * percent specifies the character used as a percent sign; the default
261    * value is the percent character (%).
262    *
263    * @param v Character to use as percent
264    */

265   public void setPercent(char v)
266   {
267     m_dfs.setPercent(v);
268   }
269
270   /**
271    * Get the "percent" attribute.
272    * percent specifies the character used as a percent sign; the default
273    * value is the percent character (%).
274    *
275    * @return Character to use as percent
276    */

277   public char getPercent()
278   {
279     return m_dfs.getPercent();
280   }
281
282   /**
283    * Set the "per-mille" attribute.
284    * per-mille specifies the character used as a per mille sign; the default
285    * value is the Unicode per-mille character (#x2030).
286    *
287    * @param v Character to use as per-mille
288    */

289   public void setPerMille(char v)
290   {
291     m_dfs.setPerMill(v);
292   }
293
294   /**
295    * Get the "per-mille" attribute.
296    * per-mille specifies the character used as a per mille sign; the default
297    * value is the Unicode per-mille character (#x2030).
298    *
299    * @return Character to use as per-mille
300    */

301   public char getPerMille()
302   {
303     return m_dfs.getPerMill();
304   }
305   
306   /**
307    * Get an int constant identifying the type of element.
308    * @see org.apache.xalan.templates.Constants
309    *
310    * @return The token ID for this element
311    */

312   public int getXSLToken()
313   {
314     return Constants.ELEMNAME_DECIMALFORMAT;
315   }
316   
317   /**
318    * Set the "zero-digit" attribute.
319    * zero-digit specifies the character used as the digit zero; the default
320    * value is the digit zero (0).
321    *
322    * @param v Character to use as the digit zero
323    */

324   public void setZeroDigit(char v)
325   {
326     m_dfs.setZeroDigit(v);
327   }
328
329   /**
330    * Get the "zero-digit" attribute.
331    * zero-digit specifies the character used as the digit zero; the default
332    * value is the digit zero (0).
333    *
334    * @return Character to use as the digit zero
335    */

336   public char getZeroDigit()
337   {
338     return m_dfs.getZeroDigit();
339   }
340
341   /**
342    * Set the "digit" attribute.
343    * digit specifies the character used for a digit in the format pattern;
344    * the default value is the number sign character (#).
345    *
346    * @param v Character to use for a digit in format pattern
347    */

348   public void setDigit(char v)
349   {
350     m_dfs.setDigit(v);
351   }
352
353   /**
354    * Get the "digit" attribute.
355    * digit specifies the character used for a digit in the format pattern;
356    * the default value is the number sign character (#).
357    *
358    * @return Character to use for a digit in format pattern
359    */

360   public char getDigit()
361   {
362     return m_dfs.getDigit();
363   }
364
365   /**
366    * Set the "pattern-separator" attribute.
367    * pattern-separator specifies the character used to separate positive
368    * and negative sub patterns in a pattern; the default value is the
369    * semi-colon character (;).
370    *
371    * @param v Character to use as a pattern separator
372    */

373   public void setPatternSeparator(char v)
374   {
375     m_dfs.setPatternSeparator(v);
376   }
377
378   /**
379    * Get the "pattern-separator" attribute.
380    * pattern-separator specifies the character used to separate positive
381    * and negative sub patterns in a pattern; the default value is the
382    * semi-colon character (;).
383    *
384    * @return Character to use as a pattern separator
385    */

386   public char getPatternSeparator()
387   {
388     return m_dfs.getPatternSeparator();
389   }
390
391   /**
392    * This function is called to recompose() all of the decimal format properties elements.
393    *
394    * @param root Stylesheet root
395    */

396   public void recompose(StylesheetRoot root)
397   {
398     root.recomposeDecimalFormats(this);
399   }
400
401 }
402
Popular Tags