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

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

public class ConfluenceXMLEventWriter
extends java.lang.Object
implements javax.xml.stream.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(javax.xml.stream.XMLEventWriter xmlEventWriter, java.io.Writer writer)
           
 
Method Summary
 void add(javax.xml.stream.events.XMLEvent event)
           
 void add(javax.xml.stream.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()
           
 javax.xml.namespace.NamespaceContext getNamespaceContext()
           
 java.lang.String getPrefix(java.lang.String uri)
           
 boolean isHandlingRequired(javax.xml.stream.events.Characters characters)
           
 java.lang.String marshalCharacters(javax.xml.stream.events.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(java.lang.String uri)
           
 void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
           
 void setPrefix(java.lang.String prefix, java.lang.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(javax.xml.stream.XMLEventWriter xmlEventWriter,
                                java.io.Writer writer)
Method Detail

add

public void add(javax.xml.stream.events.XMLEvent event)
         throws javax.xml.stream.XMLStreamException
Specified by:
add in interface javax.xml.stream.util.XMLEventConsumer
Specified by:
add in interface javax.xml.stream.XMLEventWriter
Throws:
javax.xml.stream.XMLStreamException

add

public void add(javax.xml.stream.XMLEventReader reader)
         throws javax.xml.stream.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 javax.xml.stream.XMLEventWriter
Parameters:
reader -
Throws:
javax.xml.stream.XMLStreamException

isHandlingRequired

public boolean isHandlingRequired(javax.xml.stream.events.Characters characters)

marshalCharacters

public java.lang.String marshalCharacters(javax.xml.stream.events.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 javax.xml.stream.XMLStreamException
Specified by:
flush in interface javax.xml.stream.XMLEventWriter
Throws:
javax.xml.stream.XMLStreamException

close

public void close()
           throws javax.xml.stream.XMLStreamException
Specified by:
close in interface javax.xml.stream.XMLEventWriter
Throws:
javax.xml.stream.XMLStreamException

getPrefix

public java.lang.String getPrefix(java.lang.String uri)
                           throws javax.xml.stream.XMLStreamException
Specified by:
getPrefix in interface javax.xml.stream.XMLEventWriter
Throws:
javax.xml.stream.XMLStreamException

setPrefix

public void setPrefix(java.lang.String prefix,
                      java.lang.String uri)
               throws javax.xml.stream.XMLStreamException
Specified by:
setPrefix in interface javax.xml.stream.XMLEventWriter
Throws:
javax.xml.stream.XMLStreamException

setDefaultNamespace

public void setDefaultNamespace(java.lang.String uri)
                         throws javax.xml.stream.XMLStreamException
Specified by:
setDefaultNamespace in interface javax.xml.stream.XMLEventWriter
Throws:
javax.xml.stream.XMLStreamException

setNamespaceContext

public void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
                         throws javax.xml.stream.XMLStreamException
Specified by:
setNamespaceContext in interface javax.xml.stream.XMLEventWriter
Throws:
javax.xml.stream.XMLStreamException

getNamespaceContext

public javax.xml.namespace.NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface javax.xml.stream.XMLEventWriter


Copyright © 2003-2014 Atlassian. All Rights Reserved.