KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hdf > model > util > NumberFormatter


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

17         
18
19
20 package org.apache.poi.hdf.model.util;
21
22
23 /**
24  * Comment me
25  *
26  * @author Ryan Ackley
27  */

28
29 public class NumberFormatter
30 {
31   private final static int ARABIC = 0;
32   private final static int UPPER_ROMAN = 1;
33   private final static int LOWER_ROMAN = 2;
34   private final static int UPPER_LETTER = 3;
35   private final static int LOWER_LETTER = 4;
36   private final static int ORDINAL = 5;
37
38   private static String JavaDoc[] _arabic = new String JavaDoc[] {"1", "2", "3", "4", "5", "6",
39                                                   "7", "8", "9", "10", "11", "12",
40                                                   "13", "14", "15", "16", "17", "18",
41                                                   "19", "20", "21", "22", "23",
42                                                   "24", "25", "26", "27", "28",
43                                                   "29", "30", "31", "32", "33",
44                                                   "34", "35", "36", "37", "38",
45                                                   "39", "40", "41", "42", "43",
46                                                   "44", "45", "46", "47", "48",
47                                                   "49", "50", "51", "52", "53"};
48   private static String JavaDoc[] _roman = new String JavaDoc[]{"i", "ii", "iii", "iv", "v", "vi",
49                                                 "vii", "viii", "ix", "x", "xi", "xii",
50                                                 "xiii","xiv", "xv", "xvi", "xvii",
51                                                 "xviii", "xix", "xx", "xxi", "xxii",
52                                                 "xxiii", "xxiv", "xxv", "xxvi",
53                                                 "xxvii", "xxviii", "xxix", "xxx",
54                                                 "xxxi", "xxxii", "xxxiii", "xxxiv",
55                                                 "xxxv", "xxxvi", "xxxvii", "xxxvii",
56                                                 "xxxviii", "xxxix", "xl", "xli", "xlii",
57                                                 "xliii", "xliv", "xlv", "xlvi", "xlvii",
58                                                 "xlviii", "xlix", "l"};
59   private static String JavaDoc[] _letter = new String JavaDoc[]{"a", "b", "c", "d", "e", "f", "g",
60                                                  "h", "i", "j", "k", "l", "m", "n",
61                                                  "o", "p", "q", "r", "s", "t", "u",
62                                                  "v", "x", "y", "z"};
63   public NumberFormatter()
64   {
65   }
66   public static String JavaDoc getNumber(int num, int style)
67   {
68     switch(style)
69     {
70       case ARABIC:
71         return _arabic[num - 1];
72       case UPPER_ROMAN:
73         return _roman[num-1].toUpperCase();
74       case LOWER_ROMAN:
75         return _roman[num-1];
76       case UPPER_LETTER:
77         return _letter[num-1].toUpperCase();
78       case LOWER_LETTER:
79         return _letter[num-1];
80       case ORDINAL:
81         return _arabic[num - 1];
82       default:
83         return _arabic[num - 1];
84     }
85   }
86 }
87
Popular Tags