com.atlassian.confluence.content.render.xhtml
Class ConfluenceXMLEventWriter

java.lang.Object
  extended by com.atlassian.confluence.content.render.xhtml.ConfluenceXMLEventWriter
All Implemented Interfaces:
XMLEventConsumer, XMLEventWriter

public class ConfluenceXMLEventWriter
extends Object
implements XMLEventWriter

This "Confluence" implementation of XMLEventWriter was introduced primarily to deal with STAX-58. The intention is to wrap the default XMLEventWriter and intercept calls to add(javax.xml.stream.events.XMLEvent) and add(javax.xml.stream.XMLEventReader) and write characters correctly (rather than allowing woodstox to handle it incorrectly).


Constructor Summary
ConfluenceXMLEventWriter(XMLEventWriter xmlEventWriter, Writer writer)
           
 
Method Summary
 void add(XMLEvent event)
           
 void add(XMLEventReader reader)
          The contract of this method specifies that all it does is loop and delegate to add(javax.xml.stream.events.XMLEvent).
 void close()
           
 void flush()
           
 NamespaceContext getNamespaceContext()
           
 String getPrefix(String uri)
           
 boolean isHandlingRequired(Characters characters)
           
 String marshalCharacters(Characters characters)
          Check for the 3 characters that should be encoded but that aren't by StAX and ensure their encoded form is used in the returned String.
 void setDefaultNamespace(String uri)
           
 void setNamespaceContext(NamespaceContext context)
           
 void setPrefix(String prefix, String uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfluenceXMLEventWriter

public ConfluenceXMLEventWriter(XMLEventWriter xmlEventWriter,
                                Writer writer)
Method Detail

add

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

add

public void add(XMLEventReader reader)
         throws XMLStreamException
The contract of this method specifies that all it does is loop and delegate to add(javax.xml.stream.events.XMLEvent). In our implementation, we do the same, except we invoke our customized version of add(javax.xml.stream.events.XMLEvent).

Specified by:
add in interface XMLEventWriter
Parameters:
reader -
Throws:
XMLStreamException

isHandlingRequired

public boolean isHandlingRequired(Characters characters)

marshalCharacters

public String marshalCharacters(Characters characters)
Check for the 3 characters that should be encoded but that aren't by StAX and ensure their encoded form is used in the returned String.

Parameters:
characters - the characters to be encoded.
Returns:
a String with the necessary entities encoded.

flush

public void flush()
           throws XMLStreamException
Specified by:
flush in interface XMLEventWriter
Throws:
XMLStreamException

close

public void close()
           throws XMLStreamException
Specified by:
close in interface XMLEventWriter
Throws:
XMLStreamException

getPrefix

public String getPrefix(String uri)
                 throws XMLStreamException
Specified by:
getPrefix in interface XMLEventWriter
Throws:
XMLStreamException

setPrefix

public void setPrefix(String prefix,
                      String uri)
               throws XMLStreamException
Specified by:
setPrefix in interface XMLEventWriter
Throws:
XMLStreamException

setDefaultNamespace

public void setDefaultNamespace(String uri)
                         throws XMLStreamException
Specified by:
setDefaultNamespace in interface XMLEventWriter
Throws:
XMLStreamException

setNamespaceContext

public void setNamespaceContext(NamespaceContext context)
                         throws XMLStreamException
Specified by:
setNamespaceContext in interface XMLEventWriter
Throws:
XMLStreamException

getNamespaceContext

public NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface XMLEventWriter


Copyright © 2003-2012 Atlassian. All Rights Reserved.