Package com.helger.xml.serialize.write
Class SafeXMLStreamWriter
- java.lang.Object
-
- com.helger.xml.serialize.write.SafeXMLStreamWriter
-
- All Implemented Interfaces:
AutoCloseable,XMLStreamWriter
public class SafeXMLStreamWriter extends Object implements XMLStreamWriter, AutoCloseable
A special stream writer, that ensures that special XML characters are handled correctly.
See https://github.com/javaee/jaxb-v2/issues/614
See https://github.com/javaee/jaxb-v2/issues/960- Since:
- 9.0.0
- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description SafeXMLStreamWriter(XMLEmitter aEmitter)
-
Method Summary
-
-
-
Constructor Detail
-
SafeXMLStreamWriter
public SafeXMLStreamWriter(@Nonnull XMLEmitter aEmitter)
-
-
Method Detail
-
isDefaultDebugMode
public static boolean isDefaultDebugMode()
-
setDefaultDebugMode
public static void setDefaultDebugMode(boolean bDefaultDebugMode)
-
isDebugMode
public final boolean isDebugMode()
- Returns:
trueif debug mode is enabled,falseif it is disabled. By default it is disabled.- See Also:
setDebugMode(boolean)
-
setDebugMode
@Nonnull public final SafeXMLStreamWriter setDebugMode(boolean bDebugMode)
Enable or disable debug mode- Parameters:
bDebugMode-trueto enable debug mode,falseto disable it.- Returns:
- this for chaining
- See Also:
isDebugMode()
-
writeStartDocument
public void writeStartDocument() throws XMLStreamException- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(@Nullable String sVersion) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(@Nonnull String sEncoding, @Nullable String sVersion) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(@Nonnull Charset aEncoding, @Nonnull EXMLVersion eVersion)
-
writeDTD
public void writeDTD(@Nonnull String sDTD) throws XMLStreamException
- Specified by:
writeDTDin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String sLocalName) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(@Nullable String sNamespaceURI, String sLocalName) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(@Nullable String sPrefix, String sLocalName, @Nullable String sNamespaceURI) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String sLocalName) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(@Nullable String sNamespaceURI, String sLocalName) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(@Nullable String sPrefix, String sLocalName, @Nullable String sNamespaceURI) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String sLocalName, String sValue) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(@Nullable String sNamespaceURI, String sLocalName, String sValue) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(@Nullable String sPrefix, @Nullable String sNamespaceURI, String sLocalName, String sValue) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeNamespace
public void writeNamespace(@Nullable String sPrefix, @Nonnull String sNamespaceURI) throws XMLStreamException
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDefaultNamespace
public void writeDefaultNamespace(@Nonnull String sNamespaceURI) throws XMLStreamException
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndElement
public void writeEndElement() throws XMLStreamException- Specified by:
writeEndElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeComment
public void writeComment(String sData) throws XMLStreamException
- Specified by:
writeCommentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCData
public void writeCData(String sData) throws XMLStreamException
- Specified by:
writeCDatain interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEntityRef
public void writeEntityRef(String sName) throws XMLStreamException
- Specified by:
writeEntityRefin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(String sText) throws XMLStreamException
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(char[] aText, int nStart, int nLen) throws XMLStreamException- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(@Nonnull String sTarget) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(@Nonnull String sTarget, @Nullable String sData) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndDocument
public void writeEndDocument() throws XMLStreamException- Specified by:
writeEndDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
flush
public void flush() throws XMLStreamException- Specified by:
flushin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
close
public void close() throws XMLStreamException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getPrefix
public String getPrefix(@Nonnull String sUri) throws XMLStreamException
- Specified by:
getPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setPrefix
public void setPrefix(@Nonnull String sPrefix, @Nonnull String sUri) throws XMLStreamException
- Specified by:
setPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setDefaultNamespace
public void setDefaultNamespace(@Nonnull String sUri) throws XMLStreamException
- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setNamespaceContext
public void setNamespaceContext(@Nullable NamespaceContext aContext) throws XMLStreamException
- Specified by:
setNamespaceContextin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getNamespaceContext
@Nonnull public NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContextin interfaceXMLStreamWriter
-
getProperty
@Nullable public Object getProperty(String sName)
- Specified by:
getPropertyin interfaceXMLStreamWriter
-
create
@Nonnull public static SafeXMLStreamWriter create(@Nonnull @WillCloseWhenClosed Writer aWriter, @Nonnull IXMLWriterSettings aSettings)
-
create
@Nonnull public static SafeXMLStreamWriter create(@Nonnull @WillCloseWhenClosed OutputStream aOS, @Nonnull IXMLWriterSettings aSettings)
-
-