aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-04-05 17:52:42 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-04-07 11:40:01 +0000
commit0f86dc815c46f5bde00e42fc875ed0502a1fac44 (patch)
tree54661f592792a5c35f6e7b5ec0134f995dcaebf4 /src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
parentc0b4e2c5cc15c749afba7a238d6337c7c4d66004 (diff)
4.25 of 5: Writing of UnwrittenMergedAndroidData
Introduces the AndroidDataWriter and AndroidDataWritingVisitor to abstract the io operations from the data classes. Necessary refactoring to the stubbed write method on DataValue in DataAsset.writeAsset and DataResource.writeResource. New interface for the AttributeValues to reflect the simplifications of writing Resource Attributes. Of special note is the fact all xml is written into a single file, values.xml. This is following the Gradle convention and aapt has demonstrated a preference of only reading a values.xml and ignoring all other xml files in the values directory. Unless profiling demonstrates an advantage to writing multiple files (which I doubt), this merger carries on this convention. -- MOS_MIGRATED_REVID=119066611
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
index c686829385..f2525712ea 100644
--- a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
+++ b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
@@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.android;
+import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.android.ParsedAndroidData.KeyValueConsumer;
import com.google.devtools.build.android.xml.AttrXmlResourceValue;
import com.google.devtools.build.android.xml.IdXmlResourceValue;
@@ -37,7 +38,7 @@ import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
/**
- * XmlValues provides methods for getting XmlValue derived classes.
+ * {@link XmlResourceValues} provides methods for getting {@link XmlResourceValue} derived classes.
*
* <p>Acts a static factory class containing the general xml parsing logic for resources
* that are declared inside the &lt;resources&gt; tag.
@@ -58,7 +59,7 @@ public class XmlResourceValues {
private static final QName ATTR_TYPE = QName.valueOf("type");
static XmlResourceValue parsePlurals(XMLEventReader eventReader) throws XMLStreamException {
- Map<String, String> values = new HashMap<>();
+ ImmutableMap.Builder<String, String> values = ImmutableMap.builder();
for (XMLEvent element = eventReader.nextTag();
!isEndTag(element, TAG_PLURALS);
element = eventReader.nextTag()) {
@@ -68,7 +69,7 @@ public class XmlResourceValues {
eventReader.getElementText());
}
}
- return PluralXmlResourceValue.of(values);
+ return PluralXmlResourceValue.of(values.build());
}
static XmlResourceValue parseStyle(XMLEventReader eventReader, StartElement start)