Files
rr3-apk/decompiled/sources/com/amazonaws/util/XpathUtils.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

73 lines
2.4 KiB
Java

package com.amazonaws.util;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import csdk.gluads.Consts;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
/* loaded from: classes.dex */
public abstract class XpathUtils {
public static Log log = LogFactory.getLog(XpathUtils.class);
public static DocumentBuilderFactory factory = getDocumentBuilderFactory();
public static boolean isEmpty(Node node) {
return node == null;
}
public static DocumentBuilderFactory getDocumentBuilderFactory() {
try {
DocumentBuilderFactory newInstance = DocumentBuilderFactory.newInstance();
newInstance.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
newInstance.setXIncludeAware(false);
newInstance.setExpandEntityReferences(false);
return newInstance;
} catch (ParserConfigurationException unused) {
return null;
}
}
public static Document documentFrom(InputStream inputStream) {
NamespaceRemovingInputStream namespaceRemovingInputStream = new NamespaceRemovingInputStream(inputStream);
Document parse = factory.newDocumentBuilder().parse(namespaceRemovingInputStream);
namespaceRemovingInputStream.close();
return parse;
}
public static Document documentFrom(String str) {
return documentFrom(new ByteArrayInputStream(str.getBytes(StringUtils.UTF8)));
}
public static String asString(String str, Node node) {
return evaluateAsString(str, node);
}
public static String evaluateAsString(String str, Node node) {
if (isEmpty(node)) {
return null;
}
if (Consts.STRING_PERIOD.equals(str) || asNode(str, node) != null) {
return xpath().evaluate(str, node).trim();
}
return null;
}
public static Node asNode(String str, Node node) {
if (node == null) {
return null;
}
return (Node) xpath().evaluate(str, node, XPathConstants.NODE);
}
public static XPath xpath() {
return XPathFactory.newInstance().newXPath();
}
}