MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / xmlLint

Method xmlLint

src/main/java/core/packetproxy/encode/EncodeXMPP.java:91–112  ·  view source on GitHub ↗
(byte[] data)

Source from the content-addressed store, hash-verified

89 }
90
91 private byte[] xmlLint(byte[] data) {
92 try {
93
94 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
95 dbf.setValidating(false);
96 DocumentBuilder db = dbf.newDocumentBuilder();
97 db.setErrorHandler(new IgnoreErrorMsgHandler());
98 InputSource is = new InputSource(new StringReader(new String(data)));
99 Document doc = db.parse(is);
100 Transformer transformer = TransformerFactory.newInstance().newTransformer();
101 transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
102 transformer.setOutputProperty(OutputKeys.INDENT, "yes");
103 transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
104 StreamResult result = new StreamResult(new StringWriter());
105 DOMSource source = new DOMSource(doc);
106 transformer.transform(source, result);
107 return result.getWriter().toString().getBytes(StandardCharsets.UTF_8);
108 } catch (Exception e) {
109
110 return data;
111 }
112 }
113}

Callers 2

decodeClientRequestMethod · 0.95
decodeServerResponseMethod · 0.95

Calls 3

getBytesMethod · 0.65
parseMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected