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 ofXMLEventWriter
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)
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 void
add(XMLEvent event)
void
add(XMLEventReader reader)
The contract of this method specifies that all it does is loop and delegate toadd(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)
-
-
-
Constructor Detail
-
ConfluenceXMLEventWriter
public ConfluenceXMLEventWriter(XMLEventWriter xmlEventWriter, Writer writer)
-
-
Method Detail
-
add
public void add(XMLEvent event) throws XMLStreamException
- Specified by:
add
in interfaceXMLEventConsumer
- Specified by:
add
in 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:
add
in 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:
flush
in interfaceXMLEventWriter
- Throws:
XMLStreamException
-
close
public void close() throws XMLStreamException
- Specified by:
close
in interfaceXMLEventWriter
- Throws:
XMLStreamException
-
getPrefix
public String getPrefix(String uri) throws XMLStreamException
- Specified by:
getPrefix
in interfaceXMLEventWriter
- Throws:
XMLStreamException
-
setPrefix
public void setPrefix(String prefix, String uri) throws XMLStreamException
- Specified by:
setPrefix
in interfaceXMLEventWriter
- Throws:
XMLStreamException
-
setDefaultNamespace
public void setDefaultNamespace(String uri) throws XMLStreamException
- Specified by:
setDefaultNamespace
in interfaceXMLEventWriter
- Throws:
XMLStreamException
-
setNamespaceContext
public void setNamespaceContext(NamespaceContext context) throws XMLStreamException
- Specified by:
setNamespaceContext
in interfaceXMLEventWriter
- Throws:
XMLStreamException
-
getNamespaceContext
public NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContext
in interfaceXMLEventWriter
-
-