Package org.apache.cxf.staxutils
Class StaxUtils
java.lang.Object
org.apache.cxf.staxutils.StaxUtils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclose(XMLStreamReader reader) static voidclose(XMLStreamWriter writer) static XMLStreamReaderconfigureReader(XMLStreamReader reader, Integer maxChildElements, Integer maxElementDepth, Integer maxAttributeCount, Integer maxAttributeSize, Integer maxTextLength, Long maxElementCount, Long maxXMLCharacters) static XMLStreamReaderconfigureReader(XMLStreamReader xreader, Message message) static voidcopy(XMLStreamReader reader, OutputStream os) static voidcopy(XMLStreamReader reader, XMLStreamWriter writer) Copies the reader to the writer.static voidcopy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment) static voidcopy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment, boolean isThreshold) static voidcopy(Source source, OutputStream os) static voidcopy(Source source, XMLStreamWriter writer) static Documentstatic voidcopy(Document doc, XMLStreamWriter writer) static voidcopy(Element node, XMLStreamWriter writer) static XMLStreamReadercreateFilteredReader(XMLStreamReader reader, StreamFilter filter) static XMLEventFactorystatic XMLInputFactorycreateXMLInputFactory(boolean nsAware) Return a new factory so that the caller can set sticky parameters.static XMLStreamReaderstatic XMLStreamReadercreateXMLStreamReader(InputStream in, String encoding) static XMLStreamReadercreateXMLStreamReader(Reader reader) static XMLStreamReadercreateXMLStreamReader(String systemId, InputStream in) static XMLStreamReadercreateXMLStreamReader(Source source) static XMLStreamReaderstatic XMLStreamReadercreateXMLStreamReader(Document doc, String sysId) static XMLStreamReaderstatic XMLStreamReadercreateXMLStreamReader(Element el, String sysId) static XMLStreamReaderstatic XMLStreamWriterstatic XMLStreamWritercreateXMLStreamWriter(OutputStream out, String encoding) static XMLStreamWriterstatic XMLStreamWriterstatic StringgetUniquePrefix(XMLStreamWriter writer) static StringgetUniquePrefix(XMLStreamWriter writer, String namespaceURI) static StringgetUniquePrefix(XMLStreamWriter writer, String namespaceURI, boolean declare) Create a unique namespace uri/prefix combination.static booleanisSecureReader(XMLStreamReader reader, Message message) static voidstatic voidstatic voidprintXmlFragment(XMLStreamReader reader) static Documentstatic Documentread(InputStream s) static Documentstatic Documentread(DocumentBuilder builder, XMLStreamReader reader, boolean repairing) static Documentread(XMLStreamReader reader) static Documentread(XMLStreamReader reader, boolean recordLoc) static Documentstatic Documentread(InputSource s) static NodereadDocElement(Document doc, Node parent, XMLEvent ev, StaxUtils.StreamToDOMContext context) static voidreadDocElements(Document doc, Node parent, XMLStreamReader reader, boolean repairing, boolean recordLoc) static voidreadDocElements(Document doc, Node parent, XMLStreamReader reader, boolean repairing, boolean recordLoc, boolean isThreshold) static voidreadDocElements(Document doc, Node parent, XMLStreamReader reader, StaxUtils.StreamToDOMContext context) static voidreadDocElements(Node parent, XMLStreamReader reader, boolean repairing) static voidreadDocElements(Node parent, XMLStreamReader reader, boolean repairing, boolean isThreshold) static QNamereadQName(XMLStreamReader reader) Reads a QName from the element text.static booleanReturns true if currently at the start of an element, otherwise move forwards to the next element start and return true, otherwise false is returned if the end of the stream is reached.static booleanstatic booleanstatic booleantoNextTag(XMLStreamReader reader) static booleantoNextTag(DepthXMLStreamReader reader, QName endTag) static booleantoNextText(DepthXMLStreamReader reader) static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic voidwriteDocument(Document d, XMLStreamWriter writer, boolean repairing) static voidwriteDocument(Document d, XMLStreamWriter writer, boolean writeProlog, boolean repairing) static voidwriteElement(Element e, XMLStreamWriter writer, boolean repairing) Writes an Element to an XMLStreamWriter.static voidwriteElement(Element e, XMLStreamWriter writer, boolean repairing, boolean endElement) Writes an Element to an XMLStreamWriter.static voidwriteEvent(XMLEvent event, XMLStreamWriter writer) static voidwriteNode(Node n, XMLStreamWriter writer, boolean repairing) static voidwriteStartElement(XMLStreamWriter writer, String prefix, String name, String namespace) static voidwriteTo(Node node, OutputStream os) static voidwriteTo(Node node, OutputStream os, int indent) static voidstatic void
-
Field Details
-
MAX_CHILD_ELEMENTS
- See Also:
-
MAX_ELEMENT_DEPTH
- See Also:
-
MAX_ATTRIBUTE_COUNT
- See Also:
-
MAX_ATTRIBUTE_SIZE
- See Also:
-
MAX_TEXT_LENGTH
- See Also:
-
MIN_TEXT_SEGMENT
- See Also:
-
MAX_ELEMENT_COUNT
- See Also:
-
MAX_XML_CHARACTERS
- See Also:
-
ALLOW_INSECURE_PARSER
- See Also:
-
-
Method Details
-
createXMLInputFactory
Return a new factory so that the caller can set sticky parameters.- Parameters:
nsAware-- Throws:
XMLStreamException
-
createWoodstoxEventFactory
-
createXMLStreamWriter
-
createXMLStreamWriter
-
createXMLStreamWriter
-
createXMLStreamWriter
-
createFilteredReader
-
nextEvent
-
toNextText
-
toNextTag
-
toNextTag
-
writeStartElement
public static void writeStartElement(XMLStreamWriter writer, String prefix, String name, String namespace) throws XMLStreamException - Throws:
XMLStreamException
-
skipToStartOfElement
Returns true if currently at the start of an element, otherwise move forwards to the next element start and return true, otherwise false is returned if the end of the stream is reached.- Throws:
XMLStreamException
-
toNextElement
-
skipToStartOfElement
- Throws:
XMLStreamException
-
copy
- Throws:
XMLStreamException
-
copy
- Throws:
XMLStreamException
-
copy
-
copy
- Throws:
XMLStreamException
-
copy
- Throws:
XMLStreamException
-
copy
- Throws:
XMLStreamException
-
writeTo
- Throws:
XMLStreamException
-
writeTo
- Throws:
XMLStreamException
-
writeTo
- Throws:
XMLStreamException
-
writeTo
- Throws:
XMLStreamException
-
copy
Copies the reader to the writer. The start and end document methods must be handled on the writer manually.- Parameters:
reader-writer-- Throws:
XMLStreamException
-
copy
public static void copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment) throws XMLStreamException - Throws:
XMLStreamException
-
copy
public static void copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment, boolean isThreshold) throws XMLStreamException - Throws:
XMLStreamException
-
writeDocument
public static void writeDocument(Document d, XMLStreamWriter writer, boolean repairing) throws XMLStreamException - Throws:
XMLStreamException
-
writeDocument
public static void writeDocument(Document d, XMLStreamWriter writer, boolean writeProlog, boolean repairing) throws XMLStreamException - Throws:
XMLStreamException
-
writeElement
public static void writeElement(Element e, XMLStreamWriter writer, boolean repairing) throws XMLStreamException Writes an Element to an XMLStreamWriter. The writer must already have started the document (via writeStartDocument()). Also, this probably won't work with just a fragment of a document. The Element should be the root element of the document.- Parameters:
e-writer-- Throws:
XMLStreamException
-
writeElement
public static void writeElement(Element e, XMLStreamWriter writer, boolean repairing, boolean endElement) throws XMLStreamException Writes an Element to an XMLStreamWriter. The writer must already have started the document (via writeStartDocument()). Also, this probably won't work with just a fragment of a document. The Element should be the root element of the document.- Parameters:
e-writer-endElement- true if the element should be ended- Throws:
XMLStreamException
-
writeNode
public static void writeNode(Node n, XMLStreamWriter writer, boolean repairing) throws XMLStreamException - Throws:
XMLStreamException
-
read
- Throws:
XMLStreamException
-
read
- Throws:
XMLStreamException
-
read
- Throws:
XMLStreamException
-
read
- Throws:
XMLStreamExceptionIOException
-
read
- Throws:
XMLStreamException
-
read
- Throws:
XMLStreamException
-
read
- Throws:
XMLStreamException
-
read
public static Document read(DocumentBuilder builder, XMLStreamReader reader, boolean repairing) throws XMLStreamException - Throws:
XMLStreamException
-
readDocElements
public static void readDocElements(Node parent, XMLStreamReader reader, boolean repairing) throws XMLStreamException - Throws:
XMLStreamException
-
readDocElements
public static void readDocElements(Node parent, XMLStreamReader reader, boolean repairing, boolean isThreshold) throws XMLStreamException - Throws:
XMLStreamException
-
readDocElements
public static void readDocElements(Document doc, Node parent, XMLStreamReader reader, boolean repairing, boolean recordLoc) throws XMLStreamException - Parameters:
parent-reader-- Throws:
XMLStreamException
-
readDocElements
public static void readDocElements(Document doc, Node parent, XMLStreamReader reader, boolean repairing, boolean recordLoc, boolean isThreshold) throws XMLStreamException - Parameters:
parent-reader-- Throws:
XMLStreamException
-
readDocElements
public static void readDocElements(Document doc, Node parent, XMLStreamReader reader, StaxUtils.StreamToDOMContext context) throws XMLStreamException - Throws:
XMLStreamException
-
readDocElement
public static Node readDocElement(Document doc, Node parent, XMLEvent ev, StaxUtils.StreamToDOMContext context) throws XMLStreamException - Throws:
XMLStreamException
-
createXMLStreamReader
-
createXMLStreamReader
- Parameters:
in-encoding-
-
createXMLStreamReader
- Parameters:
in-
-
createXMLStreamReader
-
createXMLStreamReader
-
createXMLStreamReader
-
createXMLStreamReader
-
createXMLStreamReader
-
createXMLStreamReader
-
createXMLStreamReader
- Parameters:
reader-
-
readQName
Reads a QName from the element text. Reader must be positioned at the start tag.- Throws:
XMLStreamException
-
getUniquePrefix
public static String getUniquePrefix(XMLStreamWriter writer, String namespaceURI, boolean declare) throws XMLStreamException Create a unique namespace uri/prefix combination.- Returns:
- The namespace with the specified URI. If one doesn't exist, one is created.
- Throws:
XMLStreamException
-
getUniquePrefix
public static String getUniquePrefix(XMLStreamWriter writer, String namespaceURI) throws XMLStreamException - Throws:
XMLStreamException
-
getUniquePrefix
-
printXmlFragment
-
writeEvent
- Throws:
XMLStreamException
-
print
-
toString
-
toString
-
toString
-
toString
-
toString
-
close
- Throws:
XMLStreamException
-
close
-
isSecureReader
-
configureReader
public static XMLStreamReader configureReader(XMLStreamReader xreader, Message message) throws XMLStreamException - Throws:
XMLStreamException
-
configureReader
public static XMLStreamReader configureReader(XMLStreamReader reader, Integer maxChildElements, Integer maxElementDepth, Integer maxAttributeCount, Integer maxAttributeSize, Integer maxTextLength, Long maxElementCount, Long maxXMLCharacters) throws XMLStreamException - Throws:
XMLStreamException
-