View Javadoc

    1   package org.codehaus.xfire.jaxb;
    2
    3   import javanet.staxutils.ContentHandlerToXMLStreamWriter;
    4   import org.xml.sax.SAXException;
    5
    6   import javax.xml.stream.XMLStreamWriter;
    7   import javax.xml.transform.sax.SAXResult;
    8
    9   /***
    10   * XMLStreamReader to StaxResult converter that ignores startDocument and endDocument
    11   */
    12  public class FilteringStaxResult extends SAXResult
    13  {
    14
    15      /***
    16       * Create a new {@link javax.xml.transform.Result} that produces
    17       * a result on the specified {@link javax.xml.stream.XMLStreamWriter}
    18       *
    19       * @param writer the XMLStreamWriter
    20       * @throws IllegalArgumentException iff the writer is null
    21       */
    22      public FilteringStaxResult(XMLStreamWriter writer)
    23      {
    24          if (writer == null)
    25          {
    26              throw new IllegalArgumentException();
    27          }
    28
    29          super.setHandler(new FilteringContentHandlerToXMLStreamWriter(writer));
    30      }
    31
    32      class FilteringContentHandlerToXMLStreamWriter extends ContentHandlerToXMLStreamWriter
    33      {
    34          public FilteringContentHandlerToXMLStreamWriter(XMLStreamWriter xmlStreamWriter)
    35          {
    36              super(xmlStreamWriter);
    37          }
    38
    39          public void startDocument() throws SAXException
    40          {
    41          }
    42
    43          public void endDocument() throws SAXException
    44          {
    45          }
    46      }
    47  }
    48
    49