Package com.landawn.abacus.util
Class XMLUtil
java.lang.Object
com.landawn.abacus.util.XMLUtil
- Since:
- 0.8
- Author:
- Haiyang Li
-
Method Summary
Modifier and TypeMethodDescriptionstatic DocumentBuilder
CallrecycleContentParser
to reuse the instance.static DocumentBuilder
DocumentBuilderFactory.newDocumentBuilder()
is called.static DocumentBuilder
createDOMParser
(boolean ignoreComments, boolean ignoringElementContentWhitespace) Creates the DOM parser.static XMLStreamReader
createFilteredStreamReader
(XMLStreamReader reader, StreamFilter filter) Creates the filtered stream reader.static jakarta.xml.bind.Marshaller
createMarshaller
(Class<?> cls) Creates the marshaller.static jakarta.xml.bind.Marshaller
createMarshaller
(String contextPath) Creates the marshaller.static SAXParser
CallrecycleSAXParser
to reuse the instance.static jakarta.xml.bind.Unmarshaller
createUnmarshaller
(Class<?> cls) Creates the unmarshaller.static jakarta.xml.bind.Unmarshaller
createUnmarshaller
(String contextPath) Creates the unmarshaller.static XMLStreamReader
createXMLStreamReader
(InputStream stream) static XMLStreamReader
createXMLStreamReader
(InputStream stream, String encoding) static XMLStreamReader
createXMLStreamReader
(Reader reader) static XMLStreamWriter
createXMLStreamWriter
(OutputStream stream) static XMLStreamWriter
createXMLStreamWriter
(OutputStream stream, String encoding) static XMLStreamWriter
createXMLStreamWriter
(Writer writer) static Transformer
TransformerFactory.newTransformer()
is called.static String
getAttribute
(Node node, String attrName) Gets the attribute.getElementsByTagName
(Element node, String tagName) Gets the elements by tag name.static Node
getNextNodeByName
(Node node, String nodeName) Gets the next node by name.getNodesByName
(Node node, String nodeName) Gets the nodes by name.static String
getTextContent
(Node node) Gets the text content.static String
getTextContent
(Node node, boolean ignoreWhiteChar) Gets the text content.static boolean
isTextElement
(Node node) static String
Marshaller.marshal(Object, java.io.Writer)
is calledreadAttributes
(Node node) static void
recycleContentParser
(DocumentBuilder docBuilder) Recycle content parser.static void
recycleSAXParser
(SAXParser saxParser) Recycle SAX parser.static void
static void
transform
(Document doc, OutputStream ou) static <T> T
Unmarshaller#unmarshal(Object, java.io.Writer)
is calledstatic void
writeCharacters
(OutputStream os, char[] cbuf) static void
writeCharacters
(OutputStream os, char[] cbuf, int off, int len) static void
writeCharacters
(OutputStream os, String str) static void
writeCharacters
(OutputStream os, String str, int off, int len) static void
writeCharacters
(Writer writer, char[] cbuf) static void
writeCharacters
(Writer writer, char[] cbuf, int off, int len) static void
writeCharacters
(Writer writer, String str) static void
writeCharacters
(Writer writer, String str, int off, int len) static void
writeCharacters
(StringBuilder sb, char[] cbuf) static void
writeCharacters
(StringBuilder sb, char[] cbuf, int off, int len) static void
writeCharacters
(StringBuilder sb, String str) static void
writeCharacters
(StringBuilder sb, String str, int off, int len) static <T> T
XMLDecoder.readObject()
is called.static String
XMLEncoder.writeObject(Object)
is called.
-
Method Details
-
marshal
Marshaller.marshal(Object, java.io.Writer)
is called- Parameters:
jaxbEntity
-- Returns:
-
unmarshal
Unmarshaller#unmarshal(Object, java.io.Writer)
is called- Type Parameters:
T
-- Parameters:
cls
-xml
-- Returns:
-
createMarshaller
Creates the marshaller.- Parameters:
contextPath
-- Returns:
-
createMarshaller
Creates the marshaller.- Parameters:
cls
-- Returns:
-
createUnmarshaller
Creates the unmarshaller.- Parameters:
contextPath
-- Returns:
-
createUnmarshaller
Creates the unmarshaller.- Parameters:
cls
-- Returns:
-
createDOMParser
DocumentBuilderFactory.newDocumentBuilder()
is called. client should Cache the result for performance improvement if this method is called frequently.- Returns:
-
createDOMParser
public static DocumentBuilder createDOMParser(boolean ignoreComments, boolean ignoringElementContentWhitespace) Creates the DOM parser.- Parameters:
ignoreComments
-ignoringElementContentWhitespace
-- Returns:
-
createContentParser
CallrecycleContentParser
to reuse the instance.- Returns:
-
recycleContentParser
Recycle content parser.- Parameters:
docBuilder
-
-
createSAXParser
CallrecycleSAXParser
to reuse the instance.- Returns:
-
recycleSAXParser
Recycle SAX parser.- Parameters:
saxParser
-
-
createXMLStreamReader
- Parameters:
reader
-- Returns:
-
createXMLStreamReader
- Parameters:
stream
-- Returns:
-
createXMLStreamReader
- Parameters:
stream
-encoding
-- Returns:
-
createFilteredStreamReader
public static XMLStreamReader createFilteredStreamReader(XMLStreamReader reader, StreamFilter filter) Creates the filtered stream reader.- Parameters:
reader
-filter
-- Returns:
-
createXMLStreamWriter
- Parameters:
writer
-- Returns:
-
createXMLStreamWriter
- Parameters:
stream
-- Returns:
-
createXMLStreamWriter
- Parameters:
stream
-encoding
-- Returns:
-
createXMLTransformer
TransformerFactory.newTransformer()
is called.- Returns:
-
transform
- Parameters:
doc
-xmlFile
-
-
transform
- Parameters:
doc
-ou
-
-
xmlEncode
XMLEncoder.writeObject(Object)
is called.- Parameters:
entity
-- Returns:
-
xmlDecode
XMLDecoder.readObject()
is called.- Type Parameters:
T
-- Parameters:
xml
-- Returns:
-
getElementsByTagName
Gets the elements by tag name.- Parameters:
node
-tagName
-- Returns:
-
getNodesByName
Gets the nodes by name.- Parameters:
node
-nodeName
-- Returns:
-
getNextNodeByName
Gets the next node by name.- Parameters:
node
-nodeName
-- Returns:
-
readAttributes
- Parameters:
node
-- Returns:
-
getAttribute
Gets the attribute.- Parameters:
node
-attrName
-- Returns:
-
isTextElement
- Parameters:
node
-- Returns:
- boolean
-
getTextContent
Gets the text content.- Parameters:
node
-- Returns:
-
getTextContent
Gets the text content.- Parameters:
node
-ignoreWhiteChar
-- Returns:
-
writeCharacters
- Parameters:
sb
-cbuf
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
public static void writeCharacters(StringBuilder sb, char[] cbuf, int off, int len) throws IOException - Parameters:
sb
-cbuf
-off
-len
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
- Parameters:
sb
-str
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
public static void writeCharacters(StringBuilder sb, String str, int off, int len) throws IOException - Parameters:
sb
-str
-off
-len
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
- Parameters:
os
-cbuf
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
public static void writeCharacters(OutputStream os, char[] cbuf, int off, int len) throws IOException - Parameters:
os
-cbuf
-off
-len
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
- Parameters:
os
-str
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
public static void writeCharacters(OutputStream os, String str, int off, int len) throws IOException - Parameters:
os
-str
-off
-len
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
- Parameters:
writer
-cbuf
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
- Parameters:
writer
-cbuf
-off
-len
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
- Parameters:
writer
-str
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-
writeCharacters
- Parameters:
writer
-str
-off
-len
-- Throws:
IOException
- Signals that an I/O exception has occurred.
-