public set ( int arg0, java arg1 ) : global::java.lang.Object | ||
arg0 | int | |
arg1 | java | |
리턴 | global::java.lang.Object |
public void testFormatByPattern() { NumberFormat newNumFormat = new NumberFormat(); newNumFormat.setPattern("(\\d{3})(\\d{3})(\\d{4})"); newNumFormat.setFormat("($1) $2-$3"); List<NumberFormat> newNumberFormats = new ArrayList<NumberFormat>(); newNumberFormats.add(newNumFormat); assertEquals("(650) 253-0000", phoneUtil.formatByPattern(US_NUMBER, PhoneNumberFormat.NATIONAL, newNumberFormats)); assertEquals("+1 (650) 253-0000", phoneUtil.formatByPattern(US_NUMBER, PhoneNumberFormat.INTERNATIONAL, newNumberFormats)); assertEquals("tel:+1-650-253-0000", phoneUtil.formatByPattern(US_NUMBER, PhoneNumberFormat.RFC3966, newNumberFormats)); // $NP is set to '1' for the US. Here we check that for other NANPA countries the US rules are // followed. newNumFormat.setNationalPrefixFormattingRule("$NP ($FG)"); newNumFormat.setFormat("$1 $2-$3"); assertEquals("1 (242) 365-1234", phoneUtil.formatByPattern(BS_NUMBER, PhoneNumberFormat.NATIONAL, newNumberFormats)); assertEquals("+1 242 365-1234", phoneUtil.formatByPattern(BS_NUMBER, PhoneNumberFormat.INTERNATIONAL, newNumberFormats)); newNumFormat.setPattern("(\\d{2})(\\d{5})(\\d{3})"); newNumFormat.setFormat("$1-$2 $3"); newNumberFormats.set(0, newNumFormat); assertEquals("02-36618 300", phoneUtil.formatByPattern(IT_NUMBER, PhoneNumberFormat.NATIONAL, newNumberFormats)); assertEquals("+39 02-36618 300", phoneUtil.formatByPattern(IT_NUMBER, PhoneNumberFormat.INTERNATIONAL, newNumberFormats)); newNumFormat.setNationalPrefixFormattingRule("$NP$FG"); newNumFormat.setPattern("(\\d{2})(\\d{4})(\\d{4})"); newNumFormat.setFormat("$1 $2 $3"); newNumberFormats.set(0, newNumFormat); assertEquals("020 7031 3000", phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL, newNumberFormats)); newNumFormat.setNationalPrefixFormattingRule("($NP$FG)"); assertEquals("(020) 7031 3000", phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL, newNumberFormats)); newNumFormat.setNationalPrefixFormattingRule(""); assertEquals("20 7031 3000", phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.NATIONAL, newNumberFormats)); assertEquals("+44 20 7031 3000", phoneUtil.formatByPattern(GB_NUMBER, PhoneNumberFormat.INTERNATIONAL, newNumberFormats)); }
public RegionFile(File file) { lastModified = 0L; fileName = file; debugln((new StringBuilder()).append("REGION LOAD ").append(fileName).toString()); sizeDelta = 0; try { if (file.exists()) { lastModified = file.lastModified(); } dataFile = new RandomAccessFile(file, "rw"); if (dataFile.length() < 4096L) { for (int i = 0; i < 1024; i++) { dataFile.writeInt(0); } for (int j = 0; j < 1024; j++) { dataFile.writeInt(0); } sizeDelta += 8192; } if ((dataFile.length() & 4095L) != 0L) { for (int k = 0; k < (dataFile.length() & 4095L); k++) { dataFile.write(0); } } int l = (int) dataFile.length()/4096; sectorFree = new ArrayList(l); for (int i1 = 0; i1 < l; i1++) { sectorFree.add(Boolean.valueOf(true)); } sectorFree.set(0, Boolean.valueOf(false)); sectorFree.set(1, Boolean.valueOf(false)); dataFile.seek(0L); for (int j1 = 0; j1 < 1024; j1++) { int l1 = dataFile.readInt(); offsets[j1] = l1; if (l1 == 0 || (l1 >> 8) + (l1 & 0xff) > sectorFree.size()) { continue; } for (int j2 = 0; j2 < (l1 & 0xff); j2++) { sectorFree.set((l1 >> 8) + j2, Boolean.valueOf(false)); } } for (int k1 = 0; k1 < 1024; k1++) { int i2 = dataFile.readInt(); chunkTimestamps[k1] = i2; } } catch (IOException ioexception) { ioexception.printStackTrace(); } }