From 19535ab35ca673b21c198e16b4d0298e9f815cb8 Mon Sep 17 00:00:00 2001 From: John Carlson Date: Fri, 18 Nov 2016 17:44:03 -0600 Subject: [PATCH] Add ability to get the value of a resource --- .../resourcespoet/ResourcesPoet.java | 20 +++++++++++++++++ .../commit451/resourcespoet/ValueTest.java | 22 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 resourcespoet/src/test/java/com/commit451/resourcespoet/ValueTest.java diff --git a/resourcespoet/src/main/java/com/commit451/resourcespoet/ResourcesPoet.java b/resourcespoet/src/main/java/com/commit451/resourcespoet/ResourcesPoet.java index b70b3aa..c9108da 100644 --- a/resourcespoet/src/main/java/com/commit451/resourcespoet/ResourcesPoet.java +++ b/resourcespoet/src/main/java/com/commit451/resourcespoet/ResourcesPoet.java @@ -447,6 +447,26 @@ public ResourcesPoet remove(@NotNull Type type, @NotNull String name) { return this; } + /** + * Get the value of the current resource of this type and name + * @param type the type + * @param name the name + * @return the value or null if it does not exist + */ + @Nullable + public String value(@NotNull Type type, @NotNull String name) { + NodeList nodeList = resourceElement.getElementsByTagName(type.toString()); + for (int i=0; i