Class ConfluenceXMLEventWriter
- java.lang.Object
-
- com.atlassian.confluence.content.render.xhtml.ConfluenceXMLEventWriter
-
- All Implemented Interfaces:
XMLEventConsumer,XMLEventWriter
public class ConfluenceXMLEventWriter extends Object implements XMLEventWriter
This "Confluence" implementation ofXMLEventWriterwas 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)andadd(javax.xml.stream.XMLEventReader)and write characters correctly (rather than allowing woodstox to handle it incorrectly).
-
-
Constructor Summary
Constructors Constructor Description ConfluenceXMLEventWriter(XMLEventWriter xmlEventWriter, Writer writer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(XMLEvent event)voidadd(XMLEventReader reader)The contract of this method specifies that all it does is loop and delegate toadd(javax.xml.stream.events.XMLEvent).voidclose()voidflush()NamespaceContextgetNamespaceContext()StringgetPrefix(String uri)booleanisHandlingRequired(Characters characters)StringmarshalCharacters(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.voidsetDefaultNamespace(String uri)voidsetNamespaceContext(NamespaceContext context)voidsetPrefix(String prefix, String uri)
-
-
-
Constructor Detail
-
ConfluenceXMLEventWriter
public ConfluenceXMLEventWriter(XMLEventWriter xmlEventWriter, Writer writer)
-
-
Method Detail
-
add
public void add(XMLEvent event) throws XMLStreamException
- Specified by:
addin interfaceXMLEventConsumer- Specified by:
addin interfaceXMLEventWriter- Throws:
XMLStreamException
-
add
public void add(XMLEventReader reader) throws XMLStreamException
The contract of this method specifies that all it does is loop and delegate toadd(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:
addin interfaceXMLEventWriter- 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:
flushin interfaceXMLEventWriter- Throws:
XMLStreamException
-
close
public void close() throws XMLStreamException- Specified by:
closein interfaceXMLEventWriter- Throws:
XMLStreamException
-
getPrefix
public String getPrefix(String uri) throws XMLStreamException
- Specified by:
getPrefixin interfaceXMLEventWriter- Throws:
XMLStreamException
-
setPrefix
public void setPrefix(String prefix, String uri) throws XMLStreamException
- Specified by:
setPrefixin interfaceXMLEventWriter- Throws:
XMLStreamException
-
setDefaultNamespace
public void setDefaultNamespace(String uri) throws XMLStreamException
- Specified by:
setDefaultNamespacein interfaceXMLEventWriter- Throws:
XMLStreamException
-
setNamespaceContext
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException
- Specified by:
setNamespaceContextin interfaceXMLEventWriter- Throws:
XMLStreamException
-
getNamespaceContext
public NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContextin interfaceXMLEventWriter
-
-