com.ebmwebsourcing.easycommons.xml
Class XMLPrettyPrinter

java.lang.Object
  extended by com.ebmwebsourcing.easycommons.xml.XMLPrettyPrinter

public class XMLPrettyPrinter
extends java.lang.Object

An util class to prettify XML document

Author:
ofabre - eBM WebSourcing

Field Summary
static java.lang.ThreadLocal<javax.xml.transform.TransformerFactory> transformerFactoryThreadLocal
           
 
Constructor Summary
XMLPrettyPrinter()
           
 
Method Summary
static java.lang.String getEncoding(org.w3c.dom.Document xmlDocument)
          Return the encoding of the document.
static void prettify(java.io.InputStream in, java.io.OutputStream out)
          Prettify the xml input stream into the output stream.
static void prettify(org.w3c.dom.Node node, java.io.OutputStream out)
          Prettify the node into the output stream.
static void prettify(org.w3c.dom.Node node, java.io.OutputStream out, java.lang.String encoding)
          Prettify the node into the output stream.
static java.lang.String prettyPrint(org.w3c.dom.Document xmlDocument)
          parse the xml Document and return it pretty-printed (with correct indentations, etc..).
static java.lang.String prettyPrint(org.w3c.dom.Element node)
          parse the xml Document and return it pretty-printed (with correct indentations, etc..).
static java.lang.String prettyPrint(org.w3c.dom.Node node)
          parse the xml Document and return it pretty-printed (with correct indentations, etc..).
static java.lang.String prettyPrint(org.w3c.dom.Node xmlDocument, java.lang.String encoding)
          parse the xml String and return it pretty-printed (with correct indentations, etc..)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transformerFactoryThreadLocal

public static final java.lang.ThreadLocal<javax.xml.transform.TransformerFactory> transformerFactoryThreadLocal
Constructor Detail

XMLPrettyPrinter

public XMLPrettyPrinter()
Method Detail

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Node xmlDocument,
                                           java.lang.String encoding)
parse the xml String and return it pretty-printed (with correct indentations, etc..)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
encoding - the encoding to use
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Document xmlDocument)
parse the xml Document and return it pretty-printed (with correct indentations, etc..). Use the encoding defined at the parsing or in the document (utf8 is used if no encoding is defined)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Element node)
parse the xml Document and return it pretty-printed (with correct indentations, etc..). Use the encoding defined at the parsing or in the document (utf8 is used if no encoding is defined)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Node node)
parse the xml Document and return it pretty-printed (with correct indentations, etc..). Use the encoding defined at the parsing or in the document (utf8 is used if no encoding is defined)

Parameters:
xmlDocument - the xml document to pretty print. Must be non null
Returns:
printed string if no error occurs. If an error occurs, return an empty String

prettify

public static void prettify(org.w3c.dom.Node node,
                            java.io.OutputStream out,
                            java.lang.String encoding)
                     throws java.lang.Exception
Prettify the node into the output stream.

Parameters:
node -
out -
Throws:
java.lang.Exception

getEncoding

public static java.lang.String getEncoding(org.w3c.dom.Document xmlDocument)
Return the encoding of the document.

Parameters:
xmlDocument -
Returns:
InputEncoding or the XmlEncoding of the document, UTF-8 if not found

prettify

public static void prettify(org.w3c.dom.Node node,
                            java.io.OutputStream out)
                     throws java.lang.Exception
Prettify the node into the output stream.

Parameters:
node -
out -
Throws:
java.lang.Exception

prettify

public static void prettify(java.io.InputStream in,
                            java.io.OutputStream out)
                     throws java.lang.Exception
Prettify the xml input stream into the output stream.

Parameters:
node -
out -
Throws:
java.lang.Exception


Copyright © 2011 Petals Link. All Rights Reserved.