From: James Ahlborn Date: Wed, 7 Apr 2010 03:13:41 +0000 (+0000) Subject: resolve some todos X-Git-Tag: jackcess-1.2.0~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a262448505c7975f73db190e65707cdb683c18b3;p=jackcess.git resolve some todos git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@459 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 828f76d..c8de012 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -70,33 +70,47 @@ public class DatabaseTest extends TestCase { super(name); } - public static Database open(final TestDB testDB) throws Exception { - final Database db = Database.open(testDB.getFile(), true, _autoSync); - assertEquals("Wrong JetFormat.", testDB.getExpectedFormat(), db.getFormat()); - assertEquals("Wrong FileFormat.", testDB.getExpectedFileFormat(), - db.getFileFormat()); + public static Database open(Database.FileFormat fileFormat, File file) throws Exception { + final Database db = Database.open(file, true, _autoSync); + assertEquals("Wrong JetFormat.", fileFormat.getJetFormat(), db.getFormat()); + assertEquals("Wrong FileFormat.", fileFormat, db.getFileFormat()); return db; } - public static Database create(final Database.FileFormat fileFormat) throws Exception { + public static Database open(TestDB testDB) throws Exception { + return open(testDB.getExpectedFileFormat(), testDB.getFile()); + } + + public static Database create(Database.FileFormat fileFormat) throws Exception { return create(fileFormat, false); } - public static Database create(final Database.FileFormat fileFormat, boolean keep) throws Exception { + public static Database create(Database.FileFormat fileFormat, boolean keep) throws Exception { return Database.create(fileFormat, createTempFile(keep), _autoSync); } - public static Database openCopy(final TestDB testDB) throws Exception { + public static Database openCopy(TestDB testDB) throws Exception { return openCopy(testDB, false); } + public static Database openCopy(TestDB testDB, boolean keep) + throws Exception + { + return openCopy(testDB.getFile(), keep); + } + + public static Database openCopy(File file) + throws Exception + { + return openCopy(file, false); + } - public static Database openCopy(final TestDB testDB, boolean keep) + public static Database openCopy(File file, boolean keep) throws Exception { File tmp = createTempFile(keep); - copyFile(testDB.getFile(), tmp); + copyFile(file, tmp); return Database.open(tmp, false, _autoSync); } @@ -986,9 +1000,7 @@ public class DatabaseTest extends TestCase { && !FileFormat.V2007.equals(fileFormat)) { assertNotNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects")); } else { - // @todo Does is matter that v2003, v2007 template files have no "MSysAccessObjects" table? - System.err.println("\n*** TODO: " + getName() - + "(): Is OK that " + fileFormat.name() + " template file has no \"MSysAccessObjects\" table? ***"); + // v2003, v2007 template files have no "MSysAccessObjects" table assertNull("file format: " + fileFormat, db.getSystemTable("MSysAccessObjects")); } diff --git a/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java b/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java index 0e1efd7..7e0d722 100644 --- a/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/IndexCodesTest.java @@ -27,6 +27,7 @@ King of Prussia, PA 19406 package com.healthmarketscience.jackcess; +import java.io.File; import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.util.Arrays; @@ -142,134 +143,120 @@ public class IndexCodesTest extends TestCase { public void x_testCreateIsoFile() throws Exception { - for (final Database.FileFormat fileFormat : JetFormatTest.SUPPORTED_FILEFORMATS) { - Database db = create(fileFormat, true); + Database db = create(Database.FileFormat.V2000, true); - Table t = new TableBuilder("test") - .addColumn(new ColumnBuilder("row", DataType.TEXT).toColumn()) - .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) - .toTable(db); - - for(int i = 0; i < 256; ++i) { - String str = "AA" + ((char)i) + "AA"; - t.addRow("row" + i, str); - } - - db.close(); + Table t = new TableBuilder("test") + .addColumn(new ColumnBuilder("row", DataType.TEXT).toColumn()) + .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) + .toTable(db); + + for(int i = 0; i < 256; ++i) { + String str = "AA" + ((char)i) + "AA"; + t.addRow("row" + i, str); } + + db.close(); } public void x_testCreateAltIsoFile() throws Exception { - for (final TestDB testDB : TestDB.getSupportedForBasename(null)) { - // @todo Bank test dbFiles and create new TestDB here. - //Database db = openCopy(new File("/tmp/test_ind.mdb"), true); - Database db = openCopy(testDB, true); - - Table t = db.getTable("Table1"); - - for(int i = 0; i < 256; ++i) { - String str = "AA" + ((char)i) + "AA"; - t.addRow("row" + i, str, - (byte)42 + i, (short)53 + i, 13 * i, - (6.7d / i), null, null, true); - } + Database db = openCopy(new File("/tmp/test_ind.mdb"), true); - db.close(); + Table t = db.getTable("Table1"); + + for(int i = 0; i < 256; ++i) { + String str = "AA" + ((char)i) + "AA"; + t.addRow("row" + i, str, + (byte)42 + i, (short)53 + i, 13 * i, + (6.7d / i), null, null, true); } + + db.close(); } public void x_testWriteAllCodesMdb() throws Exception { - for (final Database.FileFormat fileFormat : JetFormatTest.SUPPORTED_FILEFORMATS) { - Database db = create(fileFormat, true); - - // Table t = new TableBuilder("Table1") - // .addColumn(new ColumnBuilder("key", DataType.TEXT).toColumn()) - // .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) - // .toTable(db); - - // for(int i = 0; i <= 0xFFFF; ++i) { - // // skip non-char chars - // char c = (char)i; - // if(Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) { - // continue; - // } - // String key = toUnicodeStr(c); - // String str = "AA" + c + "AA"; - // t.addRow(key, str); - // } - - Table t = new TableBuilder("Table5") - .addColumn(new ColumnBuilder("name", DataType.TEXT).toColumn()) - .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) - .toTable(db); - - char c = (char)0x3041; // crazy 7F 02 ... A0 - char c2 = (char)0x30A2; // crazy 7F 02 ... - char c3 = (char)0x2045; // inat 27 ... 1C - char c4 = (char)0x3043; // crazy 7F 03 ... A0 - char c5 = (char)0x3046; // crazy 7F 04 ... - char c6 = (char)0x30F6; // crazy 7F 0D ... A0 - char c7 = (char)0x3099; // unprint 03 - char c8 = (char)0x0041; // A - char c9 = (char)0x002D; // - (unprint) - char c10 = (char)0x20E1; // unprint F2 - char c11 = (char)0x309A; // unprint 04 - char c12 = (char)0x01C4; // (long extra) - char c13 = (char)0x005F; // _ (long inline) - char c14 = (char)0xFFFE; // removed - - char[] cs = new char[]{c7, c8, c3, c12, c13, c14, c, c2, c9}; - addCombos(t, 0, "", cs, 5); - - // t = new TableBuilder("Table2") - // .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) - // .toTable(db); - - // writeChars(0x0000, t); - - // t = new TableBuilder("Table3") - // .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) - // .toTable(db); - - // writeChars(0x0400, t); + Database db = create(Database.FileFormat.V2000, true); + +// Table t = new TableBuilder("Table1") +// .addColumn(new ColumnBuilder("key", DataType.TEXT).toColumn()) +// .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) +// .toTable(db); + +// for(int i = 0; i <= 0xFFFF; ++i) { +// // skip non-char chars +// char c = (char)i; +// if(Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) { +// continue; +// } +// String key = toUnicodeStr(c); +// String str = "AA" + c + "AA"; +// t.addRow(key, str); +// } + + Table t = new TableBuilder("Table5") + .addColumn(new ColumnBuilder("name", DataType.TEXT).toColumn()) + .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) + .toTable(db); + + char c = (char)0x3041; // crazy 7F 02 ... A0 + char c2 = (char)0x30A2; // crazy 7F 02 ... + char c3 = (char)0x2045; // inat 27 ... 1C + char c4 = (char)0x3043; // crazy 7F 03 ... A0 + char c5 = (char)0x3046; // crazy 7F 04 ... + char c6 = (char)0x30F6; // crazy 7F 0D ... A0 + char c7 = (char)0x3099; // unprint 03 + char c8 = (char)0x0041; // A + char c9 = (char)0x002D; // - (unprint) + char c10 = (char)0x20E1; // unprint F2 + char c11 = (char)0x309A; // unprint 04 + char c12 = (char)0x01C4; // (long extra) + char c13 = (char)0x005F; // _ (long inline) + char c14 = (char)0xFFFE; // removed + + char[] cs = new char[]{c7, c8, c3, c12, c13, c14, c, c2, c9}; + addCombos(t, 0, "", cs, 5); + +// t = new TableBuilder("Table2") +// .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) +// .toTable(db); + +// writeChars(0x0000, t); + +// t = new TableBuilder("Table3") +// .addColumn(new ColumnBuilder("data", DataType.TEXT).toColumn()) +// .toTable(db); + +// writeChars(0x0400, t); - db.close(); - } + db.close(); } public void x_testReadAllCodesMdb() throws Exception { - for (final TestDB testDB : TestDB.getSupportedForBasename(null)) { - - // Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes.mdb")); - // Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes_orig.mdb")); - // Database db = openCopy(new File("/data2/jackcess_test/testSomeMoreCodes.mdb")); - // @todo Bank test dbFiles and create new TestDB here. - //Database db = openCopy(new File("/data2/jackcess_test/testStillMoreCodes.mdb")); - Database db = openCopy(testDB); - - Table t = db.getTable("Table5"); - - Index ind = t.getIndexes().iterator().next(); - ind.initialize(); - - System.out.println("Ind " + ind); - - Cursor cursor = Cursor.createIndexCursor(t, ind); - while(cursor.moveToNextRow()) { - System.out.println("======="); - String entryStr = - entryToString(cursor.getSavepoint().getCurrentPosition()); - System.out.println("Entry Bytes: " + entryStr); - System.out.println("Value: " + cursor.getCurrentRow() + "; " + - toUnicodeStr(cursor.getCurrentRow().get("data"))); - } +// Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes.mdb")); +// Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes_orig.mdb")); +// Database db = openCopy(new File("/data2/jackcess_test/testSomeMoreCodes.mdb")); + Database db = openCopy(new File("/data2/jackcess_test/testStillMoreCodes.mdb")); + Table t = db.getTable("Table5"); + + Index ind = t.getIndexes().iterator().next(); + ind.initialize(); + + System.out.println("Ind " + ind); - db.close(); + Cursor cursor = Cursor.createIndexCursor(t, ind); + while(cursor.moveToNextRow()) { + System.out.println("======="); + String entryStr = + entryToString(cursor.getSavepoint().getCurrentPosition()); + System.out.println("Entry Bytes: " + entryStr); + System.out.println("Value: " + cursor.getCurrentRow() + "; " + + toUnicodeStr(cursor.getCurrentRow().get("data"))); } + + db.close(); } private int addCombos(Table t, int rowNum, String s, char[] cs, int len) @@ -301,209 +288,201 @@ public class IndexCodesTest extends TestCase { public void x_testReadIsoMdb() throws Exception { - for (final TestDB testDB : TestDB.getSupportedForBasename(null)) { - // Database db = open(new File("/tmp/test_ind.mdb")); - // Database db = open(new File("/tmp/test_ind2.mdb")); - // @todo Bank test dbFiles and create new TestDB here. - //Database db = open(new File("/tmp/test_ind3.mdb")); - Database db = open(testDB); - // Database db = open(new File("/tmp/test_ind4.mdb")); - - Table t = db.getTable("Table1"); - Index index = t.getIndex("B"); - index.initialize(); - System.out.println("Ind " + index); - - Cursor cursor = Cursor.createIndexCursor(t, index); - while(cursor.moveToNextRow()) { - System.out.println("======="); - System.out.println("Savepoint: " + cursor.getSavepoint()); - System.out.println("Value: " + cursor.getCurrentRow()); - } +// Database db = open(new File("/tmp/test_ind.mdb")); +// Database db = open(new File("/tmp/test_ind2.mdb")); + Database db = open(Database.FileFormat.V2000, new File("/tmp/test_ind3.mdb")); +// Database db = open(new File("/tmp/test_ind4.mdb")); - db.close(); + Table t = db.getTable("Table1"); + Index index = t.getIndex("B"); + index.initialize(); + System.out.println("Ind " + index); + + Cursor cursor = Cursor.createIndexCursor(t, index); + while(cursor.moveToNextRow()) { + System.out.println("======="); + System.out.println("Savepoint: " + cursor.getSavepoint()); + System.out.println("Value: " + cursor.getCurrentRow()); } + + db.close(); } public void x_testReverseIsoMdb() throws Exception { - for (final TestDB testDB : TestDB.getSupportedForBasename(null)) { - // @todo Bank test dbFiles and create new TestDB here. - //Database db = open(new File("/data2/jackcess_test/testAllIndexCodes3.mdb")); - Database db = open(testDB); - - Table t = db.getTable("Table1"); - Index index = t.getIndexes().iterator().next(); - index.initialize(); - System.out.println("Ind " + index); - - Pattern inlinePat = Pattern.compile("7F 4A 4A (.*)4A 4A 01 00"); - Pattern unprintPat = Pattern.compile("01 01 01 80 (.+) 06 (.+) 00"); - Pattern unprint2Pat = Pattern.compile("4A 4A 4A 4A 01 02 (.+) 00"); - Pattern inatPat = Pattern.compile("7F 4A 4A (.*)4A 4A 01 02 02 (.+) 00"); - Pattern inat2Pat = Pattern.compile("7F 4A 4A (.*)4A 4A 01 (02 02 (.+))?01 01 (.*)FF 02 80 FF 80 00"); - - Map inlineCodes = new TreeMap(); - Map unprintCodes = new TreeMap(); - Map unprint2Codes = new TreeMap(); - Map inatInlineCodes = new TreeMap(); - Map inatExtraCodes = new TreeMap(); - Map inat2Codes = new TreeMap(); - Map inat2ExtraCodes = new TreeMap(); - Map inat2CrazyCodes = new TreeMap(); - - - Cursor cursor = Cursor.createIndexCursor(t, index); - while(cursor.moveToNextRow()) { - // System.out.println("======="); - // System.out.println("Savepoint: " + cursor.getSavepoint()); - // System.out.println("Value: " + cursor.getCurrentRow()); - Cursor.Savepoint savepoint = cursor.getSavepoint(); - String entryStr = entryToString(savepoint.getCurrentPosition()); - - Map row = cursor.getCurrentRow(); - String value = (String)row.get("data"); - String key = (String)row.get("key"); - char c = value.charAt(2); - System.out.println("======="); - System.out.println("RowId: " + - savepoint.getCurrentPosition().getRowId()); - System.out.println("Entry: " + entryStr); - // System.out.println("Row: " + row); - System.out.println("Value: (" + key + ")" + value); - System.out.println("Char: " + c + ", " + (int)c + ", " + - toUnicodeStr(c)); - - String type = null; - if(entryStr.endsWith("01 00")) { - - // handle inline codes - type = "INLINE"; - Matcher m = inlinePat.matcher(entryStr); - m.find(); - handleInlineEntry(m.group(1), c, inlineCodes); - - } else if(entryStr.contains("01 01 01 80")) { - - // handle most unprintable codes - type = "UNPRINTABLE"; - Matcher m = unprintPat.matcher(entryStr); - m.find(); - handleUnprintableEntry(m.group(2), c, unprintCodes); - - } else if(entryStr.contains("01 02 02") && - !entryStr.contains("FF 02 80 FF 80")) { - - // handle chars w/ symbols - type = "CHAR_WITH_SYMBOL"; - Matcher m = inatPat.matcher(entryStr); - m.find(); - handleInternationalEntry(m.group(1), m.group(2), c, - inatInlineCodes, inatExtraCodes); - - } else if(entryStr.contains("4A 4A 4A 4A 01 02")) { - - // handle chars w/ symbols - type = "UNPRINTABLE_2"; - Matcher m = unprint2Pat.matcher(entryStr); - m.find(); - handleUnprintable2Entry(m.group(1), c, unprint2Codes); - - } else if(entryStr.contains("FF 02 80 FF 80")) { - - type = "CRAZY_INAT"; - Matcher m = inat2Pat.matcher(entryStr); - m.find(); - handleInternational2Entry(m.group(1), m.group(3), m.group(4), c, - inat2Codes, inat2ExtraCodes, - inat2CrazyCodes); + Database db = open(Database.FileFormat.V2000, new File("/data2/jackcess_test/testAllIndexCodes3.mdb")); + + Table t = db.getTable("Table1"); + Index index = t.getIndexes().iterator().next(); + index.initialize(); + System.out.println("Ind " + index); + + Pattern inlinePat = Pattern.compile("7F 4A 4A (.*)4A 4A 01 00"); + Pattern unprintPat = Pattern.compile("01 01 01 80 (.+) 06 (.+) 00"); + Pattern unprint2Pat = Pattern.compile("4A 4A 4A 4A 01 02 (.+) 00"); + Pattern inatPat = Pattern.compile("7F 4A 4A (.*)4A 4A 01 02 02 (.+) 00"); + Pattern inat2Pat = Pattern.compile("7F 4A 4A (.*)4A 4A 01 (02 02 (.+))?01 01 (.*)FF 02 80 FF 80 00"); + + Map inlineCodes = new TreeMap(); + Map unprintCodes = new TreeMap(); + Map unprint2Codes = new TreeMap(); + Map inatInlineCodes = new TreeMap(); + Map inatExtraCodes = new TreeMap(); + Map inat2Codes = new TreeMap(); + Map inat2ExtraCodes = new TreeMap(); + Map inat2CrazyCodes = new TreeMap(); + + + Cursor cursor = Cursor.createIndexCursor(t, index); + while(cursor.moveToNextRow()) { +// System.out.println("======="); +// System.out.println("Savepoint: " + cursor.getSavepoint()); +// System.out.println("Value: " + cursor.getCurrentRow()); + Cursor.Savepoint savepoint = cursor.getSavepoint(); + String entryStr = entryToString(savepoint.getCurrentPosition()); - } else { + Map row = cursor.getCurrentRow(); + String value = (String)row.get("data"); + String key = (String)row.get("key"); + char c = value.charAt(2); + System.out.println("======="); + System.out.println("RowId: " + + savepoint.getCurrentPosition().getRowId()); + System.out.println("Entry: " + entryStr); +// System.out.println("Row: " + row); + System.out.println("Value: (" + key + ")" + value); + System.out.println("Char: " + c + ", " + (int)c + ", " + + toUnicodeStr(c)); + + String type = null; + if(entryStr.endsWith("01 00")) { + + // handle inline codes + type = "INLINE"; + Matcher m = inlinePat.matcher(entryStr); + m.find(); + handleInlineEntry(m.group(1), c, inlineCodes); + + } else if(entryStr.contains("01 01 01 80")) { + + // handle most unprintable codes + type = "UNPRINTABLE"; + Matcher m = unprintPat.matcher(entryStr); + m.find(); + handleUnprintableEntry(m.group(2), c, unprintCodes); + + } else if(entryStr.contains("01 02 02") && + !entryStr.contains("FF 02 80 FF 80")) { + + // handle chars w/ symbols + type = "CHAR_WITH_SYMBOL"; + Matcher m = inatPat.matcher(entryStr); + m.find(); + handleInternationalEntry(m.group(1), m.group(2), c, + inatInlineCodes, inatExtraCodes); + + } else if(entryStr.contains("4A 4A 4A 4A 01 02")) { + + // handle chars w/ symbols + type = "UNPRINTABLE_2"; + Matcher m = unprint2Pat.matcher(entryStr); + m.find(); + handleUnprintable2Entry(m.group(1), c, unprint2Codes); + + } else if(entryStr.contains("FF 02 80 FF 80")) { + + type = "CRAZY_INAT"; + Matcher m = inat2Pat.matcher(entryStr); + m.find(); + handleInternational2Entry(m.group(1), m.group(3), m.group(4), c, + inat2Codes, inat2ExtraCodes, + inat2CrazyCodes); + + } else { + + throw new RuntimeException("unhandled " + entryStr); + } + + System.out.println("Type: " + type); + } - throw new RuntimeException("unhandled " + entryStr); - } + System.out.println("\n***CODES"); + for(int i = 0; i <= 0xFFFF; ++i) { - System.out.println("Type: " + type); + if(i == 256) { + System.out.println("\n***EXTENDED CODES"); } - System.out.println("\n***CODES"); - for(int i = 0; i <= 0xFFFF; ++i) { - - if(i == 256) { - System.out.println("\n***EXTENDED CODES"); - } - - // skip non-char chars - char c = (char)i; - if(Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) { - continue; - } - - if(c == (char)0xFFFE) { - // this gets replaced with FFFD, treat it the same - c = (char)0xFFFD; - } + // skip non-char chars + char c = (char)i; + if(Character.isHighSurrogate(c) || Character.isLowSurrogate(c)) { + continue; + } - Character cc = c; - String[] chars = inlineCodes.get(cc); - if(chars != null) { - if((chars.length == 1) && (chars[0].length() == 0)) { - System.out.println("X"); - } else { - System.out.println("S" + toByteString(chars)); - } - continue; - } + if(c == (char)0xFFFE) { + // this gets replaced with FFFD, treat it the same + c = (char)0xFFFD; + } - chars = inatInlineCodes.get(cc); - if(chars != null) { - String[] extra = inatExtraCodes.get(cc); - System.out.println("I" + toByteString(chars) + "," + - toByteString(extra)); - continue; + Character cc = c; + String[] chars = inlineCodes.get(cc); + if(chars != null) { + if((chars.length == 1) && (chars[0].length() == 0)) { + System.out.println("X"); + } else { + System.out.println("S" + toByteString(chars)); } + continue; + } - chars = unprintCodes.get(cc); - if(chars != null) { - System.out.println("U" + toByteString(chars)); - continue; - } + chars = inatInlineCodes.get(cc); + if(chars != null) { + String[] extra = inatExtraCodes.get(cc); + System.out.println("I" + toByteString(chars) + "," + + toByteString(extra)); + continue; + } + + chars = unprintCodes.get(cc); + if(chars != null) { + System.out.println("U" + toByteString(chars)); + continue; + } - chars = unprint2Codes.get(cc); - if(chars != null) { - if(chars.length > 1) { - throw new RuntimeException("long unprint codes"); - } - int val = Integer.parseInt(chars[0], 16) - 2; - String valStr = ByteUtil.toHexString(new byte[]{(byte)val}).trim(); - System.out.println("P" + valStr); - continue; + chars = unprint2Codes.get(cc); + if(chars != null) { + if(chars.length > 1) { + throw new RuntimeException("long unprint codes"); } + int val = Integer.parseInt(chars[0], 16) - 2; + String valStr = ByteUtil.toHexString(new byte[]{(byte)val}).trim(); + System.out.println("P" + valStr); + continue; + } - chars = inat2Codes.get(cc); - if(chars != null) { - String [] crazyCodes = inat2CrazyCodes.get(cc); - String crazyCode = ""; - if(crazyCodes != null) { - if((crazyCodes.length != 1) || !"A0".equals(crazyCodes[0])) { - throw new RuntimeException("CC " + Arrays.asList(crazyCodes)); - } - crazyCode = "1"; + chars = inat2Codes.get(cc); + if(chars != null) { + String [] crazyCodes = inat2CrazyCodes.get(cc); + String crazyCode = ""; + if(crazyCodes != null) { + if((crazyCodes.length != 1) || !"A0".equals(crazyCodes[0])) { + throw new RuntimeException("CC " + Arrays.asList(crazyCodes)); } - - String[] extra = inat2ExtraCodes.get(cc); - System.out.println("Z" + toByteString(chars) + "," + - toByteString(extra) + "," + - crazyCode); - continue; + crazyCode = "1"; } - throw new RuntimeException("Unhandled char " + toUnicodeStr(c)); + String[] extra = inat2ExtraCodes.get(cc); + System.out.println("Z" + toByteString(chars) + "," + + toByteString(extra) + "," + + crazyCode); + continue; } - System.out.println("\n***END CODES"); - db.close(); + throw new RuntimeException("Unhandled char " + toUnicodeStr(c)); } + System.out.println("\n***END CODES"); + + db.close(); } private static String toByteString(String[] chars)