ICU-12510 set the UResource.Sink.put() Key more simply from the key field of the bundle
X-SVN-Rev: 38654
This commit is contained in:
parent
87a89d4df0
commit
8f7dd3149c
@ -510,25 +510,13 @@ 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.
|
||||
|
||||
// Re-fetch the path keys: They may differ from the original ones
|
||||
// if we had followed an alias.
|
||||
int depth = getResDepth();
|
||||
String[] pathKeys = new String[depth];
|
||||
getResPathKeys(pathKeys, depth);
|
||||
|
||||
int expectedType;
|
||||
if (sink != null) {
|
||||
expectedType = NONE;
|
||||
if (depth == 0) {
|
||||
key.setToEmpty();
|
||||
} else {
|
||||
key.setString(pathKeys[depth - 1]);
|
||||
}
|
||||
ICUResourceBundleImpl impl = (ICUResourceBundleImpl)this;
|
||||
readerValue.reader = impl.wholeBundle.reader;
|
||||
readerValue.res = impl.getResource();
|
||||
sink.put(key, readerValue, parent == null);
|
||||
sink.put(key.setString(this.key), readerValue, parent == null);
|
||||
} else {
|
||||
expectedType = arraySink != null ? ARRAY : TABLE;
|
||||
if (getType() == expectedType) {
|
||||
@ -544,9 +532,14 @@ public class ICUResourceBundle extends UResourceBundle {
|
||||
// any fallback from the parent bundle is still possible.
|
||||
ICUResourceBundle parentBundle = (ICUResourceBundle)parent;
|
||||
ICUResourceBundle rb;
|
||||
int depth = getResDepth();
|
||||
if (depth == 0) {
|
||||
rb = parentBundle;
|
||||
} else {
|
||||
// Re-fetch the path keys: They may differ from the original ones
|
||||
// if we had followed an alias.
|
||||
String[] pathKeys = new String[depth];
|
||||
getResPathKeys(pathKeys, depth);
|
||||
rb = findResourceWithFallback(pathKeys, 0, parentBundle, null);
|
||||
}
|
||||
if (rb != null && (expectedType == NONE || rb.getType() == expectedType)) {
|
||||
|
@ -65,26 +65,28 @@ public final class UResource {
|
||||
* @param keyBytes new key string byte array
|
||||
* @param keyOffset new key string offset
|
||||
*/
|
||||
public void setBytes(byte[] keyBytes, int keyOffset) {
|
||||
public Key setBytes(byte[] keyBytes, int keyOffset) {
|
||||
bytes = keyBytes;
|
||||
offset = keyOffset;
|
||||
for (length = 0; keyBytes[keyOffset + length] != 0; ++length) {}
|
||||
s = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates this key to an empty resource key string.
|
||||
*/
|
||||
public void setToEmpty() {
|
||||
public Key setToEmpty() {
|
||||
bytes = null;
|
||||
offset = length = 0;
|
||||
s = "";
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates this key to be equal to the given string.
|
||||
*/
|
||||
public void setString(String s) {
|
||||
public Key setString(String s) {
|
||||
if (s.isEmpty()) {
|
||||
setToEmpty();
|
||||
} else {
|
||||
@ -101,6 +103,7 @@ public final class UResource {
|
||||
}
|
||||
this.s = s;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user