Skip to content

Commit efa4f19

Browse files
Remove redundant XmlUtils.elementValue()
1 parent bfe05fb commit efa4f19

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

src/jdk.jpackage/share/classes/jdk/jpackage/internal/AppImageFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private static Map<String, String> queryProperties(Element e, XPath xPath, Stri
286286
return XmlUtils.queryNodes(e, xPath, xpathExpr)
287287
.map(Element.class::cast)
288288
.collect(toMap(Node::getNodeName, selectedElement -> {
289-
return XmlUtils.elementValue(selectedElement, xPath);
289+
return selectedElement.getTextContent();
290290
}, (a, b) -> b));
291291
}
292292

src/jdk.jpackage/share/classes/jdk/jpackage/internal/util/XmlUtils.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.nio.file.Path;
3232
import java.util.Collection;
3333
import java.util.Optional;
34-
import java.util.stream.Collectors;
3534
import java.util.stream.IntStream;
3635
import java.util.stream.Stream;
3736
import javax.xml.parsers.DocumentBuilder;
@@ -48,7 +47,6 @@
4847
import javax.xml.xpath.XPath;
4948
import javax.xml.xpath.XPathConstants;
5049
import javax.xml.xpath.XPathExpressionException;
51-
import org.w3c.dom.Element;
5250
import org.w3c.dom.NamedNodeMap;
5351
import org.w3c.dom.Node;
5452
import org.w3c.dom.NodeList;
@@ -137,13 +135,4 @@ public static Stream<Node> toStream(NamedNodeMap nodes) {
137135
return IntStream.range(0, v.getLength()).mapToObj(v::item);
138136
}).orElseGet(Stream::of);
139137
}
140-
141-
public static String elementValue(Element e, XPath xPath) {
142-
try {
143-
return queryNodes(e, xPath, "text()").map(Node::getNodeValue).collect(Collectors.joining());
144-
} catch (XPathExpressionException ex) {
145-
// Should never happen
146-
throw new RuntimeException(ex);
147-
}
148-
}
149138
}

test/jdk/tools/jpackage/junit/share/jdk.jpackage/jdk/jpackage/internal/AppImageFileTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private static Stream<Arguments> testValidXml() {
229229
"<with-comment>a<!-- This is a comment -->b</with-comment>",
230230
"<add-launcher name='a'><name>foo</name><bar>foo</bar><service>true</service></add-launcher>",
231231
"<other><nested>false</nested></other>",
232-
"<another-other><child/></another-other>")
232+
"<another-other>A<child/>B</another-other>")
233233
)
234234
);
235235
}

0 commit comments

Comments
 (0)