KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > number > Numberer_de


1 package com.icl.saxon.number;
2
3 /**
4   * Class Numberer_de is designed simply to demonstrate how to write a number formatter
5   * for a different language. This one will be activated for language="de", format="eins",
6   * letter-value="traditional"
7   * @author <A HREF="mailto:mhkay@iclway.co.uk>Michael H. Kay</A>
8   * @version 18 November 1999
9   */

10
11 public class Numberer_de extends Numberer_en {
12
13     /**
14     * Format a number into a string
15     * @param number The number to be formatted
16     * @param picture The format specification. This is a single component of the format attribute
17     * of xsl:number, e.g. "1", "01", "i", or "a"
18     * @param groupSize number of digits per group (0 implies no grouping)
19     * @param groupSeparator string to appear between groups of digits
20     * @param letterValue as defined in xsl:number ("alphabetic" or "traditional" or "")
21     * @return the formatted number
22     */

23
24     public String JavaDoc format(int number, String JavaDoc picture,
25                                  int groupSize, String JavaDoc groupSeparator,
26                                  String JavaDoc letterValue) {
27         if (letterValue.equals("traditional") && picture.equals("eins")) {
28             switch(number) {
29                 case 1: return "eins";
30                 case 2: return "zwei";
31                 case 3: return "drei";
32                 case 4: return "vier";
33                 case 5: return "funf";
34                 case 6: return "sechs";
35                 case 7: return "sieben";
36                 case 8: return "acht";
37                 case 9: return "neun";
38                 case 10: return "zehn";
39                 default: return "" + number;
40             }
41         } else {
42             return super.format(number, picture, groupSize, groupSeparator, letterValue);
43         }
44     }
45 }
46
47 //
48
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
49
// you may not use this file except in compliance with the License. You may obtain a copy of the
50
// License at http://www.mozilla.org/MPL/
51
//
52
// Software distributed under the License is distributed on an "AS IS" basis,
53
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
54
// See the License for the specific language governing rights and limitations under the License.
55
//
56
// The Original Code is: all this file.
57
//
58
// The Initial Developer of the Original Code is
59
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
60
//
61
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
62
//
63
// Contributor(s): none.
64
//
65
Popular Tags