diff options
author | Googler <noreply@google.com> | 2016-04-05 17:52:42 +0000 |
---|---|---|
committer | Lukacs Berki <lberki@google.com> | 2016-04-07 11:40:01 +0000 |
commit | 0f86dc815c46f5bde00e42fc875ed0502a1fac44 (patch) | |
tree | 54661f592792a5c35f6e7b5ec0134f995dcaebf4 /src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java | |
parent | c0b4e2c5cc15c749afba7a238d6337c7c4d66004 (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/FullyQualifiedName.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java b/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java index ccdc6617a4..303196cbfa 100644 --- a/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java +++ b/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java @@ -21,6 +21,7 @@ import com.google.common.collect.Ordering; import com.android.resources.ResourceType; +import java.nio.file.Paths; import java.util.List; import java.util.Objects; import java.util.regex.Matcher; @@ -44,6 +45,32 @@ public class FullyQualifiedName implements DataKey, Comparable<FullyQualifiedNam private final String resourceName; /** + * Returns a string path representation of the FullyQualifiedName. + * + * Non-values Android Resource have a well defined file layout: From the resource directory, + * they reside in <resource type>[-<qualifier>]/<resource name>[.extension] + * + * @param sourceExtension The extension of the resource represented by the FullyQualifiedName + * @return A string representation of the FullyQualifiedName with the provided extension. + */ + public String toPathString(String sourceExtension) { + // TODO(corysmith): Does the extension belong in the FullyQualifiedName? + return Paths.get( + Joiner.on("-") + .join( + ImmutableList.<String>builder() + .add(resourceType.getName()) + .addAll(qualifiers) + .build()), + resourceName + sourceExtension) + .toString(); + } + + public String name() { + return resourceName; + } + + /** * A factory for parsing an generating FullyQualified names with qualifiers and package. */ public static class Factory { |