Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(955)

Unified Diff: main/classes/collate/src/com/ibm/icu/impl/coll/CollationRoot.java

Issue 121870043: ICU ticket #10939: ICU4J optionally read data from .dat and .res (Closed) Base URL: http://source.icu-project.org/repos/icu/icu4j/branches/markus/mapdata/
Patch Set: code review changes r36102 Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: main/classes/collate/src/com/ibm/icu/impl/coll/CollationRoot.java
===================================================================
--- main/classes/collate/src/com/ibm/icu/impl/coll/CollationRoot.java (revision 36076)
+++ main/classes/collate/src/com/ibm/icu/impl/coll/CollationRoot.java (revision 36102)
@@ -12,12 +12,11 @@
package com.ibm.icu.impl.coll;
import java.io.IOException;
-import java.io.InputStream;
+import java.nio.ByteBuffer;
import java.util.MissingResourceException;
import com.ibm.icu.impl.ICUBinary;
import com.ibm.icu.impl.ICUData;
-import com.ibm.icu.impl.ICUResourceBundle;
/**
* Collation root provider.
@@ -42,20 +41,20 @@
}
static { // Corresponds to C++ load() function.
- CollationTailoring t = new CollationTailoring(null);
- // TODO: Optionally load from a .dat file or stand-alone .icu file.
- String path = ICUResourceBundle.ICU_BUNDLE + "/coll/ucadata.icu";
- InputStream is = ICUData.getRequiredStream(path);
+ CollationTailoring t = null;
RuntimeException e2 = null;
try {
- CollationDataReader.read(null, ICUBinary.getByteBufferFromInputStream(is), t);
+ ByteBuffer bytes = ICUBinary.getRequiredData("coll/ucadata.icu");
+ CollationTailoring t2 = new CollationTailoring(null);
+ CollationDataReader.read(null, bytes, t2);
+ // Keep t=null until after the root data has been read completely.
+ // Otherwise we would set a non-null root object if the data reader throws an exception.
+ t = t2;
} catch(IOException e) {
- t = null;
e2 = new MissingResourceException(
"IOException while reading CLDR root data",
- "CollationRoot", path);
+ "CollationRoot", ICUData.ICU_BUNDLE + "/coll/ucadata.icu");
} catch(RuntimeException e) {
- t = null;
e2 = e;
}
rootSingleton = t;

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b