195 private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT = 5;
196 // maximum number for simple case country entry default currency digits
197 private static final int SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS = 9;
198 // mask for special case country entries
199 private static final int SPECIAL_CASE_COUNTRY_MASK = 0x00000200;
200 // mask for special case country index
201 private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x0000001F;
202 // delta from entry index component in main table to index into special case tables
203 private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1;
204 // mask for distinguishing simple and special case countries
205 private static final int COUNTRY_TYPE_MASK = SIMPLE_CASE_COUNTRY_MASK | SPECIAL_CASE_COUNTRY_MASK;
206 // mask for the numeric code of the currency
207 private static final int NUMERIC_CODE_MASK = 0x000FFC00;
208 // shift count for the numeric code of the currency
209 private static final int NUMERIC_CODE_SHIFT = 10;
210
211 // Currency data format version
212 private static final int VALID_FORMAT_VERSION = 2;
213
214 static {
215 AccessController.doPrivileged(new PrivilegedAction<Void>() {
216 @Override
217 public Void run() {
218 try {
219 try (InputStream in = getClass().getResourceAsStream("/java/util/currency.data")) {
220 if (in == null) {
221 throw new InternalError("Currency data not found");
222 }
223 DataInputStream dis = new DataInputStream(new BufferedInputStream(in));
224 if (dis.readInt() != MAGIC_NUMBER) {
225 throw new InternalError("Currency data is possibly corrupted");
226 }
227 formatVersion = dis.readInt();
228 if (formatVersion != VALID_FORMAT_VERSION) {
229 throw new InternalError("Currency data format is incorrect");
230 }
231 dataVersion = dis.readInt();
232 mainTable = readIntArray(dis, A_TO_Z * A_TO_Z);
233 int scCount = dis.readInt();
234 scCutOverTimes = readLongArray(dis, scCount);
235 scOldCurrencies = readStringArray(dis, scCount);
|
195 private static final int SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT = 5;
196 // maximum number for simple case country entry default currency digits
197 private static final int SIMPLE_CASE_COUNTRY_MAX_DEFAULT_DIGITS = 9;
198 // mask for special case country entries
199 private static final int SPECIAL_CASE_COUNTRY_MASK = 0x00000200;
200 // mask for special case country index
201 private static final int SPECIAL_CASE_COUNTRY_INDEX_MASK = 0x0000001F;
202 // delta from entry index component in main table to index into special case tables
203 private static final int SPECIAL_CASE_COUNTRY_INDEX_DELTA = 1;
204 // mask for distinguishing simple and special case countries
205 private static final int COUNTRY_TYPE_MASK = SIMPLE_CASE_COUNTRY_MASK | SPECIAL_CASE_COUNTRY_MASK;
206 // mask for the numeric code of the currency
207 private static final int NUMERIC_CODE_MASK = 0x000FFC00;
208 // shift count for the numeric code of the currency
209 private static final int NUMERIC_CODE_SHIFT = 10;
210
211 // Currency data format version
212 private static final int VALID_FORMAT_VERSION = 2;
213
214 static {
215 AccessController.doPrivileged(new PrivilegedAction<>() {
216 @Override
217 public Void run() {
218 try {
219 try (InputStream in = getClass().getResourceAsStream("/java/util/currency.data")) {
220 if (in == null) {
221 throw new InternalError("Currency data not found");
222 }
223 DataInputStream dis = new DataInputStream(new BufferedInputStream(in));
224 if (dis.readInt() != MAGIC_NUMBER) {
225 throw new InternalError("Currency data is possibly corrupted");
226 }
227 formatVersion = dis.readInt();
228 if (formatVersion != VALID_FORMAT_VERSION) {
229 throw new InternalError("Currency data format is incorrect");
230 }
231 dataVersion = dis.readInt();
232 mainTable = readIntArray(dis, A_TO_Z * A_TO_Z);
233 int scCount = dis.readInt();
234 scCutOverTimes = readLongArray(dis, scCount);
235 scOldCurrencies = readStringArray(dis, scCount);
|