1 50 package com.lowagie.text.factories; 51 52 import com.lowagie.text.SpecialSymbol; 53 54 62 public class GreekNumberFactory { 63 68 public static final String getString(int index) { 69 return getString(index, true); 70 } 71 72 77 public static final String getLowerCaseString(int index) { 78 return getString(index); 79 } 80 81 86 public static final String getUpperCaseString(int index) { 87 return getString(index).toUpperCase(); 88 } 89 90 95 public static final String getString(int index, boolean lowercase) { 96 if (index < 1) return ""; 97 index--; 98 99 int bytes = 1; 100 int start = 0; 101 int symbols = 24; 102 while(index >= symbols + start) { 103 bytes++; 104 start += symbols; 105 symbols *= 24; 106 } 107 108 int c = index - start; 109 char[] value = new char[bytes]; 110 while(bytes > 0) { 111 bytes--; 112 value[bytes] = (char)(c % 24); 113 if (value[bytes] > 16) value[bytes]++; 114 value[bytes] += (lowercase ? 945 : 913); 115 value[bytes] = SpecialSymbol.getCorrespondingSymbol(value[bytes]); 116 c /= 24; 117 } 118 119 return String.valueOf(value); 120 } 121 122 125 public static void main(String [] args) { 126 for (int i = 1; i < 1000; i++) { 127 System.out.println(getString(i)); 128 } 129 } 130 } 131 | Popular Tags |