01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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: package org.apache.poi.hdf.model.util;
19:
20: /**
21: * Comment me
22: *
23: * @author Ryan Ackley
24: */
25:
26: public class NumberFormatter {
27: private final static int ARABIC = 0;
28: private final static int UPPER_ROMAN = 1;
29: private final static int LOWER_ROMAN = 2;
30: private final static int UPPER_LETTER = 3;
31: private final static int LOWER_LETTER = 4;
32: private final static int ORDINAL = 5;
33:
34: private static String[] _arabic = new String[] { "1", "2", "3",
35: "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
36: "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
37: "25", "26", "27", "28", "29", "30", "31", "32", "33", "34",
38: "35", "36", "37", "38", "39", "40", "41", "42", "43", "44",
39: "45", "46", "47", "48", "49", "50", "51", "52", "53" };
40: private static String[] _roman = new String[] { "i", "ii", "iii",
41: "iv", "v", "vi", "vii", "viii", "ix", "x", "xi", "xii",
42: "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix", "xx",
43: "xxi", "xxii", "xxiii", "xxiv", "xxv", "xxvi", "xxvii",
44: "xxviii", "xxix", "xxx", "xxxi", "xxxii", "xxxiii",
45: "xxxiv", "xxxv", "xxxvi", "xxxvii", "xxxvii", "xxxviii",
46: "xxxix", "xl", "xli", "xlii", "xliii", "xliv", "xlv",
47: "xlvi", "xlvii", "xlviii", "xlix", "l" };
48: private static String[] _letter = new String[] { "a", "b", "c",
49: "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
50: "p", "q", "r", "s", "t", "u", "v", "x", "y", "z" };
51:
52: public NumberFormatter() {
53: }
54:
55: public static String getNumber(int num, int style) {
56: switch (style) {
57: case ARABIC:
58: return _arabic[num - 1];
59: case UPPER_ROMAN:
60: return _roman[num - 1].toUpperCase();
61: case LOWER_ROMAN:
62: return _roman[num - 1];
63: case UPPER_LETTER:
64: return _letter[num - 1].toUpperCase();
65: case LOWER_LETTER:
66: return _letter[num - 1];
67: case ORDINAL:
68: return _arabic[num - 1];
69: default:
70: return _arabic[num - 1];
71: }
72: }
73: }
|