StaxUtils (Apache CXF JavaDoc 3.0.4.redhat-621177 API)

org.apache.cxf.staxutils

## Class StaxUtils

- java.lang.Object
- - org.apache.cxf.staxutils.StaxUtils

-     public final class StaxUtils
      extends Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `StaxUtils.StreamToDOMContext`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ALLOW_INSECURE_PARSER`
    `static String` | `MAX_ATTRIBUTE_COUNT`
    `static String` | `MAX_ATTRIBUTE_SIZE`
    `static String` | `MAX_CHILD_ELEMENTS`
    `static String` | `MAX_ELEMENT_COUNT`
    `static String` | `MAX_ELEMENT_DEPTH`
    `static String` | `MAX_TEXT_LENGTH`
    `static String` | `MAX_XML_CHARACTERS`
    `static String` | `MIN_TEXT_SEGMENT`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `close(XMLStreamReader reader)`
    `static void` | `close(XMLStreamWriter writer)`
    `static XMLStreamReader` | `configureReader(XMLStreamReader reader, Integer maxChildElements, Integer maxElementDepth, Integer maxAttributeCount, Integer maxAttributeSize, Integer maxTextLength, Long maxElementCount, Long maxXMLCharacters)`
    `static XMLStreamReader` | `configureReader(XMLStreamReader xreader, Message message)`
    `static Document` | `copy(Document doc)`
    `static void` | `copy(Document doc, XMLStreamWriter writer)`
    `static void` | `copy(Element node, XMLStreamWriter writer)`
    `static void` | `copy(Source source, OutputStream os)`
    `static void` | `copy(Source source, XMLStreamWriter writer)`
    `static void` | `copy(XMLStreamReader reader, OutputStream os)`
    `static void` | `copy(XMLStreamReader reader, XMLStreamWriter writer)` Copies the reader to the writer.
    `static void` | `copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment)`
    `static void` | `copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment, boolean isThreshold)`
    `static XMLStreamReader` | `createFilteredReader(XMLStreamReader reader, StreamFilter filter)`
    `static XMLInputFactory` | `createXMLInputFactory(boolean nsAware)` Return a new factory so that the caller can set sticky parameters.
    `static XMLStreamReader` | `createXMLStreamReader(Document doc)`
    `static XMLStreamReader` | `createXMLStreamReader(Document doc, String sysId)`
    `static XMLStreamReader` | `createXMLStreamReader(Element el)`
    `static XMLStreamReader` | `createXMLStreamReader(Element el, String sysId)`
    `static XMLStreamReader` | `createXMLStreamReader(InputSource src)`
    `static XMLStreamReader` | `createXMLStreamReader(InputStream in)`
    `static XMLStreamReader` | `createXMLStreamReader(InputStream in, String encoding)`
    `static XMLStreamReader` | `createXMLStreamReader(Reader reader)`
    `static XMLStreamReader` | `createXMLStreamReader(Source source)`
    `static XMLStreamReader` | `createXMLStreamReader(String systemId, InputStream in)`
    `static XMLStreamWriter` | `createXMLStreamWriter(OutputStream out)`
    `static XMLStreamWriter` | `createXMLStreamWriter(OutputStream out, String encoding)`
    `static XMLStreamWriter` | `createXMLStreamWriter(Result r)`
    `static XMLStreamWriter` | `createXMLStreamWriter(Writer out)`
    `static String` | `getUniquePrefix(XMLStreamWriter writer)`
    `static String` | `getUniquePrefix(XMLStreamWriter writer, String namespaceURI)`
    `static String` | `getUniquePrefix(XMLStreamWriter writer, String namespaceURI, boolean declare)` Create a unique namespace uri/prefix combination.
    `static boolean` | `isSecureReader(XMLStreamReader reader, Message message)`
    `static boolean` | `isWoodstox()` CXF works with multiple STaX parsers.
    `static void` | `nextEvent(XMLStreamReader dr)`
    `static void` | `print(Node node)`
    `static void` | `printXmlFragment(XMLStreamReader reader)`
    `static Document` | `read(DocumentBuilder builder, XMLStreamReader reader, boolean repairing)`
    `static Document` | `read(File is)`
    `static Document` | `read(InputSource s)`
    `static Document` | `read(InputStream s)`
    `static Document` | `read(Reader s)`
    `static Document` | `read(Source s)`
    `static Document` | `read(XMLStreamReader reader)`
    `static Document` | `read(XMLStreamReader reader, boolean recordLoc)`
    `static Node` | `readDocElement(Document doc, Node parent, XMLEvent ev, StaxUtils.StreamToDOMContext context)`
    `static void` | `readDocElements(Document doc, Node parent, XMLStreamReader reader, boolean repairing, boolean recordLoc)`
    `static void` | `readDocElements(Document doc, Node parent, XMLStreamReader reader, boolean repairing, boolean recordLoc, boolean isThreshold)`
    `static void` | `readDocElements(Document doc, Node parent, XMLStreamReader reader, StaxUtils.StreamToDOMContext context)`
    `static void` | `readDocElements(Node parent, XMLStreamReader reader, boolean repairing)`
    `static void` | `readDocElements(Node parent, XMLStreamReader reader, boolean repairing, boolean isThreshold)`
    `static QName` | `readQName(XMLStreamReader reader)` Reads a QName from the element text.
    `static void` | `setInnerElementCountThreshold(int i)`
    `static void` | `setInnerElementLevelThreshold(int i)`
    `static boolean` | `skipToStartOfElement(DepthXMLStreamReader in)`
    `static boolean` | `skipToStartOfElement(XMLStreamReader in)` 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.
    `static boolean` | `toNextElement(DepthXMLStreamReader dr)`
    `static boolean` | `toNextTag(DepthXMLStreamReader reader, QName endTag)`
    `static boolean` | `toNextTag(XMLStreamReader reader)`
    `static boolean` | `toNextText(DepthXMLStreamReader reader)`
    `static String` | `toString(Document doc)`
    `static String` | `toString(Element el)`
    `static String` | `toString(Element el, int indent)`
    `static String` | `toString(Node src)`
    `static String` | `toString(Source src)`
    `static void` | `writeDocument(Document d, XMLStreamWriter writer, boolean repairing)`
    `static void` | `writeDocument(Document d, XMLStreamWriter writer, boolean writeProlog, boolean repairing)`
    `static void` | `writeElement(Element e, XMLStreamWriter writer, boolean repairing)` Writes an Element to an XMLStreamWriter.
    `static void` | `writeElement(Element e, XMLStreamWriter writer, boolean repairing, boolean endElement)` Writes an Element to an XMLStreamWriter.
    `static void` | `writeEvent(XMLEvent event, XMLStreamWriter writer)`
    `static void` | `writeNode(Node n, XMLStreamWriter writer, boolean repairing)`
    `static void` | `writeStartElement(XMLStreamWriter writer, String prefix, String name, String namespace)`
    `static void` | `writeTo(Node node, OutputStream os)`
    `static void` | `writeTo(Node node, OutputStream os, int indent)`
    `static void` | `writeTo(Node node, Writer os)`
    `static void` | `writeTo(Node node, Writer os, int indent)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MAX_CHILD_ELEMENTS

          public static final String MAX_CHILD_ELEMENTS

      See Also:
        Constant Field Values

    - #### MAX_ELEMENT_DEPTH

          public static final String MAX_ELEMENT_DEPTH

      See Also:
        Constant Field Values

    - #### MAX_ATTRIBUTE_COUNT

          public static final String MAX_ATTRIBUTE_COUNT

      See Also:
        Constant Field Values

    - #### MAX_ATTRIBUTE_SIZE

          public static final String MAX_ATTRIBUTE_SIZE

      See Also:
        Constant Field Values

    - #### MAX_TEXT_LENGTH

          public static final String MAX_TEXT_LENGTH

      See Also:
        Constant Field Values

    - #### MIN_TEXT_SEGMENT

          public static final String MIN_TEXT_SEGMENT

      See Also:
        Constant Field Values

    - #### MAX_ELEMENT_COUNT

          public static final String MAX_ELEMENT_COUNT

      See Also:
        Constant Field Values

    - #### MAX_XML_CHARACTERS

          public static final String MAX_XML_CHARACTERS

      See Also:
        Constant Field Values

    - #### ALLOW_INSECURE_PARSER

          public static final String ALLOW_INSECURE_PARSER

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### setInnerElementLevelThreshold

          public static void setInnerElementLevelThreshold(int i)

    - #### setInnerElementCountThreshold

          public static void setInnerElementCountThreshold(int i)

    - #### isWoodstox

          public static boolean isWoodstox()

      CXF works with multiple STaX parsers. When we can't find any other way to work against the different parsers, this can be used to condition code. Note: if you've got Woodstox in the class path without being the default provider, this will return the wrong answer.
      Returns:
        true if Woodstox is in the classpath.

    - #### createXMLInputFactory

          public static XMLInputFactory createXMLInputFactory(boolean nsAware)

      Return a new factory so that the caller can set sticky parameters.
      Parameters:
        `nsAware` -
      Throws:
        `XMLStreamException`

    - #### createXMLStreamWriter

          public static XMLStreamWriter createXMLStreamWriter(Writer out)

    - #### createXMLStreamWriter

          public static XMLStreamWriter createXMLStreamWriter(OutputStream out)

    - #### createXMLStreamWriter

          public static XMLStreamWriter createXMLStreamWriter(OutputStream out,
                                              String encoding)

    - #### createXMLStreamWriter

          public static XMLStreamWriter createXMLStreamWriter(Result r)

    - #### createFilteredReader

          public static XMLStreamReader createFilteredReader(XMLStreamReader reader,
                                             StreamFilter filter)

    - #### nextEvent

          public static void nextEvent(XMLStreamReader dr)

    - #### toNextText

          public static boolean toNextText(DepthXMLStreamReader reader)

    - #### toNextTag

          public static boolean toNextTag(XMLStreamReader reader)

    - #### toNextTag

          public static boolean toNextTag(DepthXMLStreamReader reader,
                          QName endTag)

    - #### writeStartElement

          public static void writeStartElement(XMLStreamWriter writer,
                               String prefix,
                               String name,
                               String namespace)
                                        throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### skipToStartOfElement

          public static boolean skipToStartOfElement(XMLStreamReader in)
                                              throws XMLStreamException

      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

          public static boolean toNextElement(DepthXMLStreamReader dr)

    - #### skipToStartOfElement

          public static boolean skipToStartOfElement(DepthXMLStreamReader in)
                                              throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### copy

          public static void copy(Source source,
                  OutputStream os)
                           throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### copy

          public static void copy(Source source,
                  XMLStreamWriter writer)
                           throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### copy

          public static Document copy(Document doc)
                               throws XMLStreamException,
                                      ParserConfigurationException

      Throws:
        `XMLStreamException`
        `ParserConfigurationException`

    - #### copy

          public static void copy(Document doc,
                  XMLStreamWriter writer)
                           throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### copy

          public static void copy(Element node,
                  XMLStreamWriter writer)
                           throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### copy

          public static void copy(XMLStreamReader reader,
                  OutputStream os)
                           throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### writeTo

          public static void writeTo(Node node,
                     OutputStream os)
                              throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### writeTo

          public static void writeTo(Node node,
                     OutputStream os,
                     int indent)
                              throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### writeTo

          public static void writeTo(Node node,
                     Writer os)
                              throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### writeTo

          public static void writeTo(Node node,
                     Writer os,
                     int indent)
                              throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### copy

          public static void copy(XMLStreamReader reader,
                  XMLStreamWriter writer)
                           throws XMLStreamException

      Copies the reader to the writer. The start and end document methods must be handled on the writer manually. TODO: if the namespace on the reader has been declared previously to where we are in the stream, this probably won't work.
      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

          public static Document read(Source s)
                               throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### read

          public static Document read(InputStream s)
                               throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### read

          public static Document read(Reader s)
                               throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### read

          public static Document read(File is)
                               throws XMLStreamException,
                                      IOException

      Throws:
        `XMLStreamException`
        `IOException`

    - #### read

          public static Document read(InputSource s)
                               throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### read

          public static Document read(XMLStreamReader reader)
                               throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### read

          public static Document read(XMLStreamReader reader,
                      boolean recordLoc)
                               throws XMLStreamException

      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

          public static XMLStreamReader createXMLStreamReader(InputSource src)

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(InputStream in,
                                              String encoding)

      Parameters:
        `in` -
        `encoding` -

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(InputStream in)

      Parameters:
        `in` -

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(String systemId,
                                              InputStream in)

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(Element el)

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(Document doc)

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(Element el,
                                              String sysId)

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(Document doc,
                                              String sysId)

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(Source source)

    - #### createXMLStreamReader

          public static XMLStreamReader createXMLStreamReader(Reader reader)

      Parameters:
        `reader` -

    - #### readQName

          public static QName readQName(XMLStreamReader reader)
                                 throws XMLStreamException

      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

          public static String getUniquePrefix(XMLStreamWriter writer)

    - #### printXmlFragment

          public static void printXmlFragment(XMLStreamReader reader)

    - #### writeEvent

          public static void writeEvent(XMLEvent event,
                        XMLStreamWriter writer)
                                 throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### print

          public static void print(Node node)

    - #### toString

          public static String toString(Source src)

    - #### toString

          public static String toString(Node src)

    - #### toString

          public static String toString(Document doc)

    - #### toString

          public static String toString(Element el)

    - #### toString

          public static String toString(Element el,
                        int indent)

    - #### close

          public static void close(XMLStreamReader reader)
                            throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### close

          public static void close(XMLStreamWriter writer)

    - #### isSecureReader

          public static boolean isSecureReader(XMLStreamReader reader,
                               Message message)

    - #### 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`

Apache CXF