From 8f7dd3149c6aaf7d7e0e481f2ff660e9a3bd1a6d Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Wed, 27 Apr 2016 16:17:11 +0000 Subject: [PATCH] ICU-12510 set the UResource.Sink.put() Key more simply from the key field of the bundle X-SVN-Rev: 38654 --- .../com/ibm/icu/impl/ICUResourceBundle.java | 19 ++++++------------- .../core/src/com/ibm/icu/impl/UResource.java | 9 ++++++--- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java index b8127f8e3f..375d10e9c1 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java @@ -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)) { diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/UResource.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/UResource.java index 1f315f3878..d790c9ff80 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/UResource.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/UResource.java @@ -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; } /**