思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c
以下内容为反编译后的 XmlUtil.java 源代码,内容仅作参考
package org.jivesoftware.smack.util;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class XmlUtil {
public static final Logger LOGGER = Logger.getLogger(XmlUtil.class.getName());
public static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
static {
try {
transformerFactory.setAttribute("indent-number", 2);
} catch (IllegalArgumentException e) {
LOGGER.log(Level.INFO, "XML TransformerFactory does not support indent-number attribute", (Throwable) e);
}
}
public static String prettyFormatXml(CharSequence charSequence) {
String charSequence2 = charSequence.toString();
StreamSource streamSource = new StreamSource(new StringReader(charSequence2));
StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter);
try {
Transformer newTransformer = transformerFactory.newTransformer();
newTransformer.setOutputProperty("omit-xml-declaration", "yes");
newTransformer.setOutputProperty("indent", "yes");
newTransformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
newTransformer.transform(streamSource, streamResult);
return stringWriter.toString();
} catch (IllegalArgumentException | TransformerException e) {
LOGGER.log(Level.SEVERE, "Transformer error", e);
return charSequence2;
}
}
}