return result;
}
- public void getAllArrayItemsWithFallback(String path, ICUResource.ArraySink sink)
+ public void getAllArrayItemsWithFallback(String path, UResource.ArraySink sink)
throws MissingResourceException {
getAllContainerItemsWithFallback(path, sink, null);
}
- public void getAllTableItemsWithFallback(String path, ICUResource.TableSink sink)
+ public void getAllTableItemsWithFallback(String path, UResource.TableSink sink)
throws MissingResourceException {
getAllContainerItemsWithFallback(path, null, sink);
}
private void getAllContainerItemsWithFallback(
- String path, ICUResource.ArraySink arraySink, ICUResource.TableSink tableSink)
+ String path, UResource.ArraySink arraySink, UResource.TableSink tableSink)
throws MissingResourceException {
// Collect existing and parsed key objects into an array of keys,
// rather than assembling and parsing paths.
throw new UResourceTypeMismatchException("");
}
// Get all table items with fallback.
- ICUResource.Key key = new ICUResource.Key();
+ UResource.Key key = new UResource.Key();
ReaderValue readerValue = new ReaderValue();
rb.getAllContainerItemsWithFallback(key, readerValue, arraySink, tableSink);
}
private void getAllContainerItemsWithFallback(
- ICUResource.Key key, ReaderValue readerValue,
- ICUResource.ArraySink arraySink, ICUResource.TableSink tableSink) {
+ UResource.Key key, ReaderValue readerValue,
+ UResource.ArraySink arraySink, UResource.TableSink tableSink) {
// We recursively enumerate child-first,
// only storing parent items in the absence of child items.
// We store a placeholder value for the no-fallback/no-inheritance marker
if (getType() == expectedType) {
if (arraySink != null) {
((ICUResourceBundleImpl.ResourceArray)this).getAllItems(key, readerValue, arraySink);
- } else if (tableSink != null) {
+ } else /* tableSink != null */ {
((ICUResourceBundleImpl.ResourceTable)this).getAllItems(key, readerValue, tableSink);
}
}
* @param readerValue will be set during enumeration; input contents is ignored
* @param sink receives all array item values
*/
- void getAllItems(ICUResource.Key key, ReaderValue readerValue, ICUResource.ArraySink sink) {
+ void getAllItems(UResource.Key key, ReaderValue readerValue, UResource.ArraySink sink) {
ICUResourceBundleReader reader = wholeBundle.reader;
readerValue.reader = reader;
((ICUResourceBundleReader.Array)value).getAllItems(reader, key, readerValue, sink);
* @param readerValue will be set during enumeration; input contents is ignored
* @param sink receives all table item key-value pairs
*/
- void getAllItems(ICUResource.Key key, ReaderValue readerValue, ICUResource.TableSink sink) {
+ void getAllItems(UResource.Key key, ReaderValue readerValue, UResource.TableSink sink) {
ICUResourceBundleReader reader = wholeBundle.reader;
readerValue.reader = reader;
((ICUResourceBundleReader.Table)value).getAllItems(reader, key, readerValue, sink);
import java.nio.CharBuffer;
import java.nio.IntBuffer;
-import com.ibm.icu.impl.ICUResource.ArraySink;
-import com.ibm.icu.impl.ICUResource.TableSink;
+import com.ibm.icu.impl.UResource.ArraySink;
+import com.ibm.icu.impl.UResource.TableSink;
import com.ibm.icu.util.ICUException;
import com.ibm.icu.util.ICUUncheckedIOException;
import com.ibm.icu.util.ULocale;
return makeKeyStringFromBytes(poolBundleReader.keyBytes, keyOffset & 0x7fffffff);
}
}
- private void setKeyFromKey16(int keyOffset, ICUResource.Key key) {
+ private void setKeyFromKey16(int keyOffset, UResource.Key key) {
if(keyOffset < localKeyLimit) {
key.setBytes(keyBytes, keyOffset);
} else {
key.setBytes(poolBundleReader.keyBytes, keyOffset - localKeyLimit);
}
}
- private void setKeyFromKey32(int keyOffset, ICUResource.Key key) {
+ private void setKeyFromKey32(int keyOffset, UResource.Key key) {
if(keyOffset >= 0) {
key.setBytes(keyBytes, keyOffset);
} else {
UResourceBundle.NONE
};
- static class ReaderValue extends ICUResource.Value {
+ static class ReaderValue extends UResource.Value {
ICUResourceBundleReader reader;
private int res;
protected int size;
protected int itemsOffset;
- int getSize() {
+ final int getSize() {
return size;
}
int getContainerResource(ICUResourceBundleReader reader, int index) {
static class Array extends Container {
Array() {}
void getAllItems(ICUResourceBundleReader reader,
- ICUResource.Key key, ReaderValue value, ArraySink sink) {
+ UResource.Key key, ReaderValue value, ArraySink sink) {
for (int i = 0; i < size; ++i) {
int res = getContainerResource(reader, i);
int type = RES_GET_TYPE(res);
return getContainerResource(reader, findTableItem(reader, resKey));
}
void getAllItems(ICUResourceBundleReader reader,
- ICUResource.Key key, ReaderValue value, TableSink sink) {
+ UResource.Key key, ReaderValue value, TableSink sink) {
for (int i = 0; i < size; ++i) {
if (keyOffsets != null) {
reader.setKeyFromKey16(keyOffsets[i], key);
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
-import com.ibm.icu.impl.ICUResource.TableSink;
import com.ibm.icu.impl.TextTrieMap.ResultHandler;
+import com.ibm.icu.impl.UResource.TableSink;
import com.ibm.icu.text.TimeZoneNames;
import com.ibm.icu.util.TimeZone;
import com.ibm.icu.util.TimeZone.SystemTimeZoneType;
/**
* Loads all meta zone and time zone names for this TimeZoneNames' locale.
*/
- private final class ZoneStringsLoader extends ICUResource.TableSink {
+ private final class ZoneStringsLoader extends UResource.TableSink {
/**
* Prepare for several hundred time zones and meta zones.
* _zoneStrings.getSize() is ineffective in a sparsely populated locale like en-GB.
*/
private static final int INITIAL_NUM_ZONES = 300;
- private HashMap<ICUResource.Key, ZNamesLoader> keyToLoader =
- new HashMap<ICUResource.Key, ZNamesLoader>(INITIAL_NUM_ZONES);
+ private HashMap<UResource.Key, ZNamesLoader> keyToLoader =
+ new HashMap<UResource.Key, ZNamesLoader>(INITIAL_NUM_ZONES);
private StringBuilder sb = new StringBuilder(32);
/** Caller must synchronize. */
void load() {
_zoneStrings.getAllTableItemsWithFallback("", this);
- for (Map.Entry<ICUResource.Key, ZNamesLoader> entry : keyToLoader.entrySet()) {
- ICUResource.Key key = entry.getKey();
+ for (Map.Entry<UResource.Key, ZNamesLoader> entry : keyToLoader.entrySet()) {
+ UResource.Key key = entry.getKey();
ZNamesLoader loader = entry.getValue();
if (loader == ZNamesLoader.DUMMY_LOADER) {
// skip
}
@Override
- public TableSink getOrCreateTableSink(ICUResource.Key key, int initialSize) {
+ public TableSink getOrCreateTableSink(UResource.Key key, int initialSize) {
ZNamesLoader loader = keyToLoader.get(key);
if (loader != null) {
if (loader == ZNamesLoader.DUMMY_LOADER) {
}
@Override
- public void putNoFallback(ICUResource.Key key) {
+ public void putNoFallback(UResource.Key key) {
if (!keyToLoader.containsKey(key)) {
keyToLoader.put(key.clone(), ZNamesLoader.DUMMY_LOADER);
}
* Equivalent to key.substring(MZ_PREFIX.length())
* except reuses our StringBuilder.
*/
- private String mzIDFromKey(ICUResource.Key key) {
+ private String mzIDFromKey(UResource.Key key) {
sb.setLength(0);
for (int i = MZ_PREFIX.length(); i < key.length(); ++i) {
sb.append(key.charAt(i));
return sb.toString();
}
- private String tzIDFromKey(ICUResource.Key key) {
+ private String tzIDFromKey(UResource.Key key) {
sb.setLength(0);
for (int i = 0; i < key.length(); ++i) {
char c = key.charAt(i);
}
}
- private static final class ZNamesLoader extends ICUResource.TableSink {
+ private static final class ZNamesLoader extends UResource.TableSink {
private static int NUM_META_ZONE_NAMES = 6;
private static int NUM_TIME_ZONE_NAMES = 7; // incl. EXEMPLAR_LOCATION
return getNames();
}
- private static NameType nameTypeFromKey(ICUResource.Key key) {
+ private static NameType nameTypeFromKey(UResource.Key key) {
// Avoid key.toString() object creation.
if (key.length() != 2) {
return null;
}
@Override
- public void put(ICUResource.Key key, ICUResource.Value value) {
+ public void put(UResource.Key key, UResource.Value value) {
if (value.getType() == UResourceBundle.STRING) {
if (names == null) {
names = new String[numNames];
}
@Override
- public void putNoFallback(ICUResource.Key key) {
+ public void putNoFallback(UResource.Key key) {
if (names == null) {
names = new String[numNames];
}
import com.ibm.icu.util.UResourceBundle;
import com.ibm.icu.util.UResourceTypeMismatchException;
+// Class UResource is named consistently with the public class UResourceBundle,
+// in case we want to make it public at some point.
+
/**
* ICU resource bundle key and value types.
*/
-public final class ICUResource {
+public final class UResource {
/**
* Represents a resource bundle item's key string.
* Avoids object creations as much as possible.