de.odysseus.staxon.json.util
Class XMLMultipleEventWriter

java.lang.Object
  extended by de.odysseus.staxon.util.EventWriterDelegate
      extended by de.odysseus.staxon.json.util.XMLMultipleEventWriter
All Implemented Interfaces:
XMLEventConsumer, XMLEventWriter

public class XMLMultipleEventWriter
extends EventWriterDelegate

Simple delegate writer which generates <?xml-multiple?> processing instructions when writing a sequence of elements matching some element path. Use this class to trigger JSON array start events like this:

 XMLOutputFactory factory = new JsonXMLOutputFactory();
 XMLEventWriter writer = factory.createXMLEventWriter(...);
 writer = new XMLMultipleEventWriter(writer, false, "/alice/bob", ...);
 


Constructor Summary
XMLMultipleEventWriter(XMLEventWriter parent, boolean matchRoot, String... multiplePaths)
          Create instance.
 
Method Summary
 void add(XMLEvent event)
           
 void add(XMLEventReader reader)
           
 void addMultiplePath(String path)
          Add path to trigger <?xml-multiple?> PI.
 void setParent(XMLEventWriter parent)
           
 
Methods inherited from class de.odysseus.staxon.util.EventWriterDelegate
close, flush, getNamespaceContext, getParent, getPrefix, setDefaultNamespace, setNamespaceContext, setPrefix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLMultipleEventWriter

public XMLMultipleEventWriter(XMLEventWriter parent,
                              boolean matchRoot,
                              String... multiplePaths)
                       throws XMLStreamException
Create instance.

Parameters:
parent - delegate
matchRoot - whether the root element is included in paths
multiplePaths - added via addMultiplePath(String)
Throws:
XMLStreamException
Method Detail

setParent

public void setParent(XMLEventWriter parent)
Overrides:
setParent in class EventWriterDelegate

addMultiplePath

public void addMultiplePath(String path)
                     throws XMLStreamException
Add path to trigger <?xml-multiple?> PI. The path may start with '/' and contain local element names, separated by '/', e.g "/foo/bar", "foo/bar" or "bar".

Parameters:
path - multiple path
Throws:
XMLStreamException - if the path is invalid

add

public void add(XMLEventReader reader)
         throws XMLStreamException
Specified by:
add in interface XMLEventWriter
Overrides:
add in class EventWriterDelegate
Throws:
XMLStreamException

add

public void add(XMLEvent event)
         throws XMLStreamException
Specified by:
add in interface XMLEventConsumer
Specified by:
add in interface XMLEventWriter
Overrides:
add in class EventWriterDelegate
Throws:
XMLStreamException


Copyright © 2011-2012. All Rights Reserved.