ICU-12634 remove UResource.TableSink and ICUResourceBundle.getAllTableItems()
X-SVN-Rev: 39097
This commit is contained in:
parent
c1b7c99189
commit
be2b7dc92e
@ -366,18 +366,6 @@ public class ICUResourceBundle extends UResourceBundle {
|
||||
|
||||
public void getAllItemsWithFallback(String path, UResource.Sink sink)
|
||||
throws MissingResourceException {
|
||||
getAllItemsWithFallback(path, sink, null);
|
||||
}
|
||||
|
||||
public void getAllTableItemsWithFallback(String path, UResource.TableSink sink)
|
||||
throws MissingResourceException {
|
||||
getAllItemsWithFallback(path, null, sink);
|
||||
}
|
||||
|
||||
private void getAllItemsWithFallback(
|
||||
String path, UResource.Sink sink,
|
||||
UResource.TableSink tableSink)
|
||||
throws MissingResourceException {
|
||||
// Collect existing and parsed key objects into an array of keys,
|
||||
// rather than assembling and parsing paths.
|
||||
int numPathKeys = countPathKeys(path); // How much deeper does the path go?
|
||||
@ -404,13 +392,11 @@ public class ICUResourceBundle extends UResourceBundle {
|
||||
}
|
||||
UResource.Key key = new UResource.Key();
|
||||
ReaderValue readerValue = new ReaderValue();
|
||||
rb.getAllItemsWithFallback(key, readerValue, sink, tableSink);
|
||||
rb.getAllItemsWithFallback(key, readerValue, sink);
|
||||
}
|
||||
|
||||
private void getAllItemsWithFallback(
|
||||
UResource.Key key, ReaderValue readerValue,
|
||||
UResource.Sink sink,
|
||||
UResource.TableSink tableSink) {
|
||||
UResource.Key key, ReaderValue readerValue, UResource.Sink sink) {
|
||||
// We recursively enumerate child-first,
|
||||
// only storing parent items in the absence of child items.
|
||||
// The sink needs to store a placeholder value for the no-fallback/no-inheritance marker
|
||||
@ -421,21 +407,11 @@ public class ICUResourceBundle extends UResourceBundle {
|
||||
// When the sink sees the no-fallback/no-inheritance marker,
|
||||
// then it would remove the parent's item.
|
||||
// We would deserialize parent values even though they are overridden in a child bundle.
|
||||
int expectedType;
|
||||
if (sink != null) {
|
||||
expectedType = NONE;
|
||||
ICUResourceBundleImpl impl = (ICUResourceBundleImpl)this;
|
||||
readerValue.reader = impl.wholeBundle.reader;
|
||||
readerValue.res = impl.getResource();
|
||||
key.setString(this.key != null ? this.key : "");
|
||||
sink.put(key, readerValue, parent == null);
|
||||
} else {
|
||||
expectedType = TABLE;
|
||||
if (getType() == expectedType) {
|
||||
// tableSink != null
|
||||
((ICUResourceBundleImpl.ResourceTable)this).getAllItems(key, readerValue, tableSink);
|
||||
}
|
||||
}
|
||||
if (parent != null) {
|
||||
// We might try to query the sink whether
|
||||
// any fallback from the parent bundle is still possible.
|
||||
@ -451,8 +427,8 @@ public class ICUResourceBundle extends UResourceBundle {
|
||||
getResPathKeys(pathKeys, depth);
|
||||
rb = findResourceWithFallback(pathKeys, 0, parentBundle, null);
|
||||
}
|
||||
if (rb != null && (expectedType == NONE || rb.getType() == expectedType)) {
|
||||
rb.getAllItemsWithFallback(key, readerValue, sink, tableSink);
|
||||
if (rb != null) {
|
||||
rb.getAllItemsWithFallback(key, readerValue, sink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.ibm.icu.impl.ICUResourceBundleReader.ReaderValue;
|
||||
import com.ibm.icu.util.UResourceBundle;
|
||||
import com.ibm.icu.util.UResourceTypeMismatchException;
|
||||
|
||||
@ -295,16 +294,6 @@ class ICUResourceBundleImpl extends ICUResourceBundle {
|
||||
}
|
||||
return reader.getString(value.getContainerResource(reader, index));
|
||||
}
|
||||
/**
|
||||
* @param key will be set during enumeration; input contents is ignored
|
||||
* @param readerValue will be set during enumeration; input contents is ignored
|
||||
* @param sink receives all table item key-value pairs
|
||||
*/
|
||||
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);
|
||||
}
|
||||
ResourceTable(ICUResourceBundleImpl container, String key, int resource) {
|
||||
super(container, key, resource);
|
||||
value = wholeBundle.reader.getTable(resource);
|
||||
|
@ -15,7 +15,6 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
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;
|
||||
@ -1051,37 +1050,6 @@ public final class ICUResourceBundleReader {
|
||||
int getResource(ICUResourceBundleReader reader, String resKey) {
|
||||
return getContainerResource(reader, findTableItem(reader, resKey));
|
||||
}
|
||||
void getAllItems(ICUResourceBundleReader reader,
|
||||
UResource.Key key, ReaderValue value, TableSink sink) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (keyOffsets != null) {
|
||||
reader.setKeyFromKey16(keyOffsets[i], key);
|
||||
} else {
|
||||
reader.setKeyFromKey32(key32Offsets[i], key);
|
||||
}
|
||||
int res = getContainerResource(reader, i);
|
||||
int type = RES_GET_TYPE(res);
|
||||
if (URES_IS_ARRAY(type)) {
|
||||
// ICU ticket #12634: This original version of the enumeration code
|
||||
// is going away. getOrCreateArraySink(key) was unused and has been removed.
|
||||
} else if (URES_IS_TABLE(type)) {
|
||||
TableSink subSink = sink.getOrCreateTableSink(key);
|
||||
if (subSink != null) {
|
||||
Table table = reader.getTable(res);
|
||||
table.getAllItems(reader, key, value, subSink);
|
||||
}
|
||||
/* TODO: settle on how to deal with aliases, port to C++
|
||||
} else if (type == ICUResourceBundle.ALIAS) {
|
||||
throw new UnsupportedOperationException(
|
||||
"aliases not handled in resource enumeration"); */
|
||||
} else if (reader.isNoInheritanceMarker(res)) {
|
||||
sink.putNoFallback(key);
|
||||
} else {
|
||||
value.res = res;
|
||||
sink.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean getKeyAndValue(int i, UResource.Key key, UResource.Value value) {
|
||||
if (0 <= i && i < size) {
|
||||
|
@ -466,45 +466,4 @@ public final class UResource {
|
||||
*/
|
||||
public abstract void put(Key key, Value value, boolean noFallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sink for ICU resource table contents.
|
||||
* The base class does nothing.
|
||||
*
|
||||
* <p>Nested arrays and tables are stored as nested sinks,
|
||||
* never put() as {@link Value} items.
|
||||
*/
|
||||
public static class TableSink {
|
||||
/**
|
||||
* Adds a key-value pair from a resource table.
|
||||
*
|
||||
* @param key resource key string
|
||||
* @param value resource value
|
||||
*/
|
||||
public void put(Key key, Value value) {}
|
||||
|
||||
/**
|
||||
* Adds a no-fallback/no-inheritance marker for this key.
|
||||
* Used for CLDR no-fallback data values of "∅∅∅"
|
||||
* when enumerating tables with fallback from the specific resource bundle to root.
|
||||
*
|
||||
* <p>The default implementation does nothing.
|
||||
*
|
||||
* @param key to be removed
|
||||
*/
|
||||
public void putNoFallback(Key key) {}
|
||||
|
||||
/**
|
||||
* Returns a nested resource table for the key as another sink.
|
||||
* Creates the sink if none exists for the key.
|
||||
* Returns null if nested tables are not supported.
|
||||
* The default implementation always returns null.
|
||||
*
|
||||
* @param key resource key string
|
||||
* @return nested-table sink, or null
|
||||
*/
|
||||
public TableSink getOrCreateTableSink(Key key) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import com.ibm.icu.impl.ICUResourceBundle;
|
||||
import com.ibm.icu.impl.SimpleCache;
|
||||
import com.ibm.icu.impl.UResource;
|
||||
import com.ibm.icu.impl.UResource.Key;
|
||||
import com.ibm.icu.impl.UResource.TableSink;
|
||||
import com.ibm.icu.impl.UResource.Value;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
@ -244,6 +243,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
* @return <code>true</code> if the specified object is equal to this <code>PatternInfo</code>.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object a) {
|
||||
if (a instanceof PatternInfo) {
|
||||
PatternInfo patternInfo = (PatternInfo)a;
|
||||
@ -259,6 +259,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
* @return A hash code value for this object.
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = fIntervalPatternFirstPart != null ? fIntervalPatternFirstPart.hashCode() : 0;
|
||||
if (fIntervalPatternSecondPart != null) {
|
||||
@ -469,11 +470,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the patterns for a skeleton table.
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
/** Processes the patterns for a skeleton table. */
|
||||
public void processSkeletonTable(Key key, Value value) {
|
||||
// Iterate over all the patterns in the current skeleton table
|
||||
String currentSkeleton = key.toString();
|
||||
@ -933,6 +930,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
* @return a copy of the object
|
||||
* @stable ICU4.0
|
||||
*/
|
||||
@Override
|
||||
public Object clone()
|
||||
{
|
||||
if ( frozen ) {
|
||||
@ -992,6 +990,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
*
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return frozen;
|
||||
}
|
||||
@ -1001,6 +1000,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
*
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
@Override
|
||||
public DateIntervalInfo freeze() {
|
||||
fIntervalPatternsReadOnly = true;
|
||||
frozen = true;
|
||||
@ -1012,6 +1012,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
*
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
@Override
|
||||
public DateIntervalInfo cloneAsThawed() {
|
||||
DateIntervalInfo result = (DateIntervalInfo) (this.cloneUnfrozenDII());
|
||||
return result;
|
||||
@ -1145,6 +1146,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
* Override equals
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object a) {
|
||||
if ( a instanceof DateIntervalInfo ) {
|
||||
DateIntervalInfo dtInfo = (DateIntervalInfo)a;
|
||||
@ -1157,6 +1159,7 @@ public class DateIntervalInfo implements Cloneable, Freezable<DateIntervalInfo>,
|
||||
* Override hashcode
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return fIntervalPatterns.hashCode();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user