aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/FullyQualifiedName.java
diff options
context:
space:
mode:
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.java27
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 &lt;resource type&gt;[-&lt;qualifier&gt;]/&lt;resource name&gt;[.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 {