org.springframework.util.xml

## 类 StaxUtils

- java.lang.Object
- - org.springframework.util.xml.StaxUtils

-     public abstract class StaxUtils
      extends Object

  Convenience methods for working with the StAX API. Partly historic due to JAXP 1.3 compatibility; as of Spring 4.0, relying on JAXP 1.4 as included in JDK 1.6 and higher.

  In particular, methods for using StAX (`javax.xml.stream`) in combination with the TrAX API (`javax.xml.transform`), and converting StAX readers/writers into SAX readers/handlers and vice-versa.

  从以下版本开始:
    3.0
  作者:
    Arjen Poutsma, Juergen Hoeller

- - ### 构造器概要

    构造器
    构造器和说明
    `StaxUtils()`

  - ### 方法概要

    所有方法 静态方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `static ContentHandler` | `createContentHandler(XMLEventWriter eventWriter)` Create a SAX `ContentHandler` that writes events to the given StAX `XMLEventWriter`.
    `static ContentHandler` | `createContentHandler(XMLStreamWriter streamWriter)` Create a SAX `ContentHandler` that writes to the given StAX `XMLStreamWriter`.
    `static Result` | `createCustomStaxResult(XMLEventWriter eventWriter)` Create a custom, non-JAXP 1.4 StAX `Result` for the given `XMLEventWriter`.
    `static Result` | `createCustomStaxResult(XMLStreamWriter streamWriter)` Create a custom, non-JAXP 1.4 StAX `Result` for the given `XMLStreamWriter`.
    `static Source` | `createCustomStaxSource(XMLEventReader eventReader)` Create a custom, non-JAXP 1.4 StAX `Source` for the given `XMLEventReader`.
    `static Source` | `createCustomStaxSource(XMLStreamReader streamReader)` Create a custom, non-JAXP 1.4 StAX `Source` for the given `XMLStreamReader`.
    `static XMLInputFactory` | `createDefensiveInputFactory()` Create an `XMLInputFactory` with Spring's defensive setup, i.e. no support for the resolution of DTDs and external entities.
    `static XMLStreamReader` | `createEventStreamReader(XMLEventReader eventReader)` Return a `XMLStreamReader` that reads from a `XMLEventReader`.
    `static XMLStreamWriter` | `createEventStreamWriter(XMLEventWriter eventWriter)` Return a `XMLStreamWriter` that writes to a `XMLEventWriter`.
    `static XMLStreamWriter` | `createEventStreamWriter(XMLEventWriter eventWriter, XMLEventFactory eventFactory)` Return a `XMLStreamWriter` that writes to a `XMLEventWriter`.
    `static Result` | `createStaxResult(XMLEventWriter eventWriter)` Create a JAXP 1.4 `StAXResult` for the given `XMLEventWriter`.
    `static Result` | `createStaxResult(XMLStreamWriter streamWriter)` Create a JAXP 1.4 `StAXResult` for the given `XMLStreamWriter`.
    `static Source` | `createStaxSource(XMLEventReader eventReader)` Create a JAXP 1.4 `StAXSource` for the given `XMLEventReader`.
    `static Source` | `createStaxSource(XMLStreamReader streamReader)` Create a JAXP 1.4 `StAXSource` for the given `XMLStreamReader`.
    `static XMLEventReader` | `createXMLEventReader(List<XMLEvent> events)` Create a `XMLEventReader` from the given list of `XMLEvent`.
    `static XMLReader` | `createXMLReader(XMLEventReader eventReader)` Create a SAX `XMLReader` that reads from the given StAX `XMLEventReader`.
    `static XMLReader` | `createXMLReader(XMLStreamReader streamReader)` Create a SAX `XMLReader` that reads from the given StAX `XMLStreamReader`.
    `static XMLEventReader` | `getXMLEventReader(Source source)` Return the `XMLEventReader` for the given StAX Source.
    `static XMLEventWriter` | `getXMLEventWriter(Result result)` Return the `XMLEventWriter` for the given StAX Result.
    `static XMLStreamReader` | `getXMLStreamReader(Source source)` Return the `XMLStreamReader` for the given StAX Source.
    `static XMLStreamWriter` | `getXMLStreamWriter(Result result)` Return the `XMLStreamWriter` for the given StAX Result.
    `static boolean` | `isStaxResult(Result result)` Indicate whether the given `Result` is a JAXP 1.4 StAX Result or custom StAX Result.
    `static boolean` | `isStaxSource(Source source)` Indicate whether the given `Source` is a JAXP 1.4 StAX Source or custom StAX Source.

    - ### 从类继承的方法 java.lang.Object

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

- - ### 构造器详细资料

    - #### StaxUtils

          public StaxUtils()

  - ### 方法详细资料

    - #### createDefensiveInputFactory

          public static XMLInputFactory createDefensiveInputFactory()

      Create an `XMLInputFactory` with Spring's defensive setup, i.e. no support for the resolution of DTDs and external entities.
      返回:
        a new input factory to use
      从以下版本开始:
        5.0

    - #### createStaxSource

          public static Source createStaxSource(XMLStreamReader streamReader)

      Create a JAXP 1.4 `StAXSource` for the given `XMLStreamReader`.
      参数:
        `streamReader` - the StAX stream reader
      返回:
        a source wrapping the `streamReader`

    - #### createStaxSource

          public static Source createStaxSource(XMLEventReader eventReader)
                                         throws XMLStreamException

      Create a JAXP 1.4 `StAXSource` for the given `XMLEventReader`.
      参数:
        `eventReader` - the StAX event reader
      返回:
        a source wrapping the `eventReader`
      抛出:
        `XMLStreamException`

    - #### createCustomStaxSource

          public static Source createCustomStaxSource(XMLStreamReader streamReader)

      Create a custom, non-JAXP 1.4 StAX `Source` for the given `XMLStreamReader`.
      参数:
        `streamReader` - the StAX stream reader
      返回:
        a source wrapping the `streamReader`

    - #### createCustomStaxSource

          public static Source createCustomStaxSource(XMLEventReader eventReader)

      Create a custom, non-JAXP 1.4 StAX `Source` for the given `XMLEventReader`.
      参数:
        `eventReader` - the StAX event reader
      返回:
        a source wrapping the `eventReader`

    - #### isStaxSource

          public static boolean isStaxSource(Source source)

      Indicate whether the given `Source` is a JAXP 1.4 StAX Source or custom StAX Source.
      返回:
        `true` if `source` is a JAXP 1.4 `StAXSource` or custom StAX Source; `false` otherwise

    - #### getXMLStreamReader

          @Nullable
          public static XMLStreamReader getXMLStreamReader(Source source)

      Return the `XMLStreamReader` for the given StAX Source.
      参数:
        `source` - a JAXP 1.4 `StAXSource`
      返回:
        the `XMLStreamReader`
      抛出:
        `IllegalArgumentException` - if `source` isn't a JAXP 1.4 `StAXSource` or custom StAX Source

    - #### getXMLEventReader

          @Nullable
          public static XMLEventReader getXMLEventReader(Source source)

      Return the `XMLEventReader` for the given StAX Source.
      参数:
        `source` - a JAXP 1.4 `StAXSource`
      返回:
        the `XMLEventReader`
      抛出:
        `IllegalArgumentException` - if `source` isn't a JAXP 1.4 `StAXSource` or custom StAX Source

    - #### createStaxResult

          public static Result createStaxResult(XMLStreamWriter streamWriter)

      Create a JAXP 1.4 `StAXResult` for the given `XMLStreamWriter`.
      参数:
        `streamWriter` - the StAX stream writer
      返回:
        a result wrapping the `streamWriter`

    - #### createStaxResult

          public static Result createStaxResult(XMLEventWriter eventWriter)

      Create a JAXP 1.4 `StAXResult` for the given `XMLEventWriter`.
      参数:
        `eventWriter` - the StAX event writer
      返回:
        a result wrapping `streamReader`

    - #### createCustomStaxResult

          public static Result createCustomStaxResult(XMLStreamWriter streamWriter)

      Create a custom, non-JAXP 1.4 StAX `Result` for the given `XMLStreamWriter`.
      参数:
        `streamWriter` - the StAX stream writer
      返回:
        a source wrapping the `streamWriter`

    - #### createCustomStaxResult

          public static Result createCustomStaxResult(XMLEventWriter eventWriter)

      Create a custom, non-JAXP 1.4 StAX `Result` for the given `XMLEventWriter`.
      参数:
        `eventWriter` - the StAX event writer
      返回:
        a source wrapping the `eventWriter`

    - #### isStaxResult

          public static boolean isStaxResult(Result result)

      Indicate whether the given `Result` is a JAXP 1.4 StAX Result or custom StAX Result.
      返回:
        `true` if `result` is a JAXP 1.4 `StAXResult` or custom StAX Result; `false` otherwise

    - #### getXMLStreamWriter

          @Nullable
          public static XMLStreamWriter getXMLStreamWriter(Result result)

      Return the `XMLStreamWriter` for the given StAX Result.
      参数:
        `result` - a JAXP 1.4 `StAXResult`
      返回:
        the `XMLStreamReader`
      抛出:
        `IllegalArgumentException` - if `source` isn't a JAXP 1.4 `StAXResult` or custom StAX Result

    - #### getXMLEventWriter

          @Nullable
          public static XMLEventWriter getXMLEventWriter(Result result)

      Return the `XMLEventWriter` for the given StAX Result.
      参数:
        `result` - a JAXP 1.4 `StAXResult`
      返回:
        the `XMLStreamReader`
      抛出:
        `IllegalArgumentException` - if `source` isn't a JAXP 1.4 `StAXResult` or custom StAX Result

    - #### createXMLEventReader

          public static XMLEventReader createXMLEventReader(List<XMLEvent> events)

      Create a `XMLEventReader` from the given list of `XMLEvent`.
      参数:
        `events` - the list of `XMLEvent`s.
      返回:
        an `XMLEventReader` that reads from the given events
      从以下版本开始:
        5.0

    - #### createContentHandler

          public static ContentHandler createContentHandler(XMLStreamWriter streamWriter)

      Create a SAX `ContentHandler` that writes to the given StAX `XMLStreamWriter`.
      参数:
        `streamWriter` - the StAX stream writer
      返回:
        a content handler writing to the `streamWriter`

    - #### createContentHandler

          public static ContentHandler createContentHandler(XMLEventWriter eventWriter)

      Create a SAX `ContentHandler` that writes events to the given StAX `XMLEventWriter`.
      参数:
        `eventWriter` - the StAX event writer
      返回:
        a content handler writing to the `eventWriter`

    - #### createXMLReader

          public static XMLReader createXMLReader(XMLStreamReader streamReader)

      Create a SAX `XMLReader` that reads from the given StAX `XMLStreamReader`.
      参数:
        `streamReader` - the StAX stream reader
      返回:
        a XMLReader reading from the `streamWriter`

    - #### createXMLReader

          public static XMLReader createXMLReader(XMLEventReader eventReader)

      Create a SAX `XMLReader` that reads from the given StAX `XMLEventReader`.
      参数:
        `eventReader` - the StAX event reader
      返回:
        a XMLReader reading from the `eventWriter`

    - #### createEventStreamReader

          public static XMLStreamReader createEventStreamReader(XMLEventReader eventReader)
                                                         throws XMLStreamException

      Return a `XMLStreamReader` that reads from a `XMLEventReader`. Useful because the StAX `XMLInputFactory` allows one to create an event reader from a stream reader, but not vice-versa.
      返回:
        a stream reader that reads from an event reader
      抛出:
        `XMLStreamException`

    - #### createEventStreamWriter

          public static XMLStreamWriter createEventStreamWriter(XMLEventWriter eventWriter)

      Return a `XMLStreamWriter` that writes to a `XMLEventWriter`.
      返回:
        a stream writer that writes to an event writer
      从以下版本开始:
        3.2

    - #### createEventStreamWriter

          public static XMLStreamWriter createEventStreamWriter(XMLEventWriter eventWriter,
                                                                XMLEventFactory eventFactory)

      Return a `XMLStreamWriter` that writes to a `XMLEventWriter`.
      返回:
        a stream writer that writes to an event writer
      从以下版本开始:
        3.0.5