@NotThreadSafe public class XMLWriterSettings extends Object implements IXMLWriterSettings, com.helger.commons.lang.ICloneable<XMLWriterSettings>
IXMLWriterSettings interface.| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEFAULT_EMIT_NAMESPACES
By default namespaces are written.
|
static EXMLIncorrectCharacterHandling |
DEFAULT_INCORRECT_CHARACTER_HANDLING
By default invalid characters are not written and a log message is emitted
|
static String |
DEFAULT_INDENTATION_STRING
By default indentation happens with 2 spaces
|
static boolean |
DEFAULT_NEW_LINE_AFTER_XML_DECLARATION
By default a newline character is emitted afterwards
|
static boolean |
DEFAULT_ORDER_ATTRIBUTES_AND_NAMESPACES
By default the insertion order of attributes is maintained
|
static boolean |
DEFAULT_PUT_NAMESPACE_CONTEXT_PREFIXES_IN_ROOT
By default namespace context prefixes are put inside the root element
|
static EXMLSerializeComments |
DEFAULT_SERIALIZE_COMMENTS
By default comments are emitted
|
static EXMLSerializeDocType |
DEFAULT_SERIALIZE_DOC_TYPE
By default the document type is emitted
|
static EXMLSerializeIndent |
DEFAULT_SERIALIZE_INDENT
By default the output is indented and aligned (newlines are added)
|
static EXMLSerializeXMLDeclaration |
DEFAULT_SERIALIZE_XML_DECLARATION
By default all fields of the XML declaration are emitted
|
static boolean |
DEFAULT_SPACE_ON_SELF_CLOSED_ELEMENT
By default a leading space is inserted before a self closed element (e.g.
|
static boolean |
DEFAULT_USE_DOUBLE_QUOTES_FOR_ATTRIBUTES
By default double quotes are used to wrap attribute values
|
static boolean |
DEFAULT_WRITE_CDATA_AS_TEXT
By default CDATA children are emitted as CDATA
|
static String |
DEFAULT_XML_CHARSET
The default charset is UTF-8
|
static Charset |
DEFAULT_XML_CHARSET_OBJ
The default charset is UTF-8
|
static EXMLSerializeVersion |
DEFAULT_XML_SERIALIZE_VERSION
Default default XML version is 1.0
|
static IXMLWriterSettings |
DEFAULT_XML_SETTINGS
The default settings to use - last constant
|
| Constructor and Description |
|---|
XMLWriterSettings()
Creates a default settings object with the following settings:
XML version 1.0
with XML declaration
with document type
with comments
Indented and aligned
Writing invalid characters to the file as is - may result in invalid
XML files
Default character set UTF-8
No namespace context
|
XMLWriterSettings(IXMLWriterSettings aOther)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static XMLWriterSettings |
createForCanonicalization()
The canonical form of an XML document is physical representation of the
document produced by the method described in this specification.
|
static XMLWriterSettings |
createForHTML4() |
static XMLWriterSettings |
createForHTML5() |
static XMLWriterSettings |
createForXHTML() |
boolean |
equals(Object o) |
IXMLBracketModeDeterminator |
getBracketModeDeterminator() |
Charset |
getCharset() |
XMLWriterSettings |
getClone() |
EXMLIncorrectCharacterHandling |
getIncorrectCharacterHandling() |
EXMLSerializeIndent |
getIndent() |
String |
getIndentationString() |
IXMLIndentDeterminator |
getIndentDeterminator() |
NamespaceContext |
getNamespaceContext() |
com.helger.commons.system.ENewLineMode |
getNewLineMode() |
EXMLSerializeComments |
getSerializeComments() |
EXMLSerializeDocType |
getSerializeDocType() |
EXMLSerializeVersion |
getSerializeVersion() |
EXMLSerializeXMLDeclaration |
getSerializeXMLDeclaration() |
EXMLVersion |
getXMLVersion() |
int |
hashCode() |
boolean |
isEmitNamespaces()
Determine if namespaces should be emitted or not.
|
boolean |
isNewLineAfterXMLDeclaration() |
boolean |
isOrderAttributesAndNamespaces()
Determine if attributes of elements and namespaces should be emitted in
alphabetical order or not.
|
boolean |
isPutNamespaceContextPrefixesInRoot()
Check if the flag for putting all namespace prefixes specified in the
namespace context should be put in the root document.
|
boolean |
isSpaceOnSelfClosedElement()
Determine if a self closed element (an element having no children) should
be emitted with a space at the end (
<br />) or not (
<br/>) |
boolean |
isUseDoubleQuotesForAttributes() |
boolean |
isWriteCDATAAsText()
Check if all CDATA children should be emitted as normal text or not.
|
XMLWriterSettings |
setBracketModeDeterminator(IXMLBracketModeDeterminator aBracketModeDeterminator) |
XMLWriterSettings |
setCharset(Charset aCharset)
Set the serialization charset.
|
XMLWriterSettings |
setEmitNamespaces(boolean bEmitNamespaces) |
XMLWriterSettings |
setIncorrectCharacterHandling(EXMLIncorrectCharacterHandling eIncorrectCharacterHandling)
Set the way how to handle invalid characters.
|
XMLWriterSettings |
setIndent(EXMLSerializeIndent eIndent)
Set the way how to indent/align
|
XMLWriterSettings |
setIndentationString(String sIndentationString) |
XMLWriterSettings |
setIndentDeterminator(IXMLIndentDeterminator aIndentDeterminator)
Set the dynamic (per-element) indent determinator to be used.
|
XMLWriterSettings |
setNamespaceContext(NamespaceContext aNamespaceContext)
Set the namespace context to be used.
|
XMLWriterSettings |
setNewLineAfterXMLDeclaration(boolean bNewLineAfterXMLDeclaration)
Change whether a newline should be printed after the XML declaration or
not.
|
XMLWriterSettings |
setNewLineMode(com.helger.commons.system.ENewLineMode eNewLineMode) |
XMLWriterSettings |
setOrderAttributesAndNamespaces(boolean bOrderAttributesAndNamespaces) |
XMLWriterSettings |
setPutNamespaceContextPrefixesInRoot(boolean bPutNamespaceContextPrefixesInRoot) |
XMLWriterSettings |
setSerializeComments(EXMLSerializeComments eSerializeComments)
Set the way how comments should be handled.
|
XMLWriterSettings |
setSerializeDocType(EXMLSerializeDocType eSerializeDocType)
Set the way how to handle the doc type.
|
XMLWriterSettings |
setSerializeVersion(EXMLSerializeVersion eSerializeVersion)
Set the preferred XML version to use.
|
XMLWriterSettings |
setSerializeXMLDeclaration(EXMLSerializeXMLDeclaration eSerializeXMLDecl)
Set the way how to handle the XML declaration.
|
XMLWriterSettings |
setSpaceOnSelfClosedElement(boolean bSpaceOnSelfClosedElement) |
XMLWriterSettings |
setUseDoubleQuotesForAttributes(boolean bUseDoubleQuotesForAttributes) |
XMLWriterSettings |
setWriteCDATAAsText(boolean bWriteCDATAAsText) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetNewLineStringpublic static final EXMLSerializeVersion DEFAULT_XML_SERIALIZE_VERSION
public static final EXMLSerializeXMLDeclaration DEFAULT_SERIALIZE_XML_DECLARATION
public static final boolean DEFAULT_NEW_LINE_AFTER_XML_DECLARATION
public static final EXMLSerializeDocType DEFAULT_SERIALIZE_DOC_TYPE
public static final EXMLSerializeComments DEFAULT_SERIALIZE_COMMENTS
public static final EXMLSerializeIndent DEFAULT_SERIALIZE_INDENT
public static final EXMLIncorrectCharacterHandling DEFAULT_INCORRECT_CHARACTER_HANDLING
public static final Charset DEFAULT_XML_CHARSET_OBJ
public static final String DEFAULT_XML_CHARSET
public static final boolean DEFAULT_USE_DOUBLE_QUOTES_FOR_ATTRIBUTES
public static final boolean DEFAULT_SPACE_ON_SELF_CLOSED_ELEMENT
<b /> in contrast to <b/>).public static final String DEFAULT_INDENTATION_STRING
public static final boolean DEFAULT_EMIT_NAMESPACES
public static final boolean DEFAULT_PUT_NAMESPACE_CONTEXT_PREFIXES_IN_ROOT
public static final boolean DEFAULT_WRITE_CDATA_AS_TEXT
public static final boolean DEFAULT_ORDER_ATTRIBUTES_AND_NAMESPACES
public static final IXMLWriterSettings DEFAULT_XML_SETTINGS
public XMLWriterSettings()
public XMLWriterSettings(@Nonnull IXMLWriterSettings aOther)
aOther - The object to copy the settings from. May not be null.@Nonnull public EXMLVersion getXMLVersion()
getXMLVersion in interface IXMLWriterSettings1.0@Nonnull public EXMLSerializeVersion getSerializeVersion()
getSerializeVersion in interface IXMLWriterSettingsXML 1.0@Nonnull public final XMLWriterSettings setSerializeVersion(@Nonnull EXMLSerializeVersion eSerializeVersion)
eSerializeVersion - The XML serialize version. May not be null.@Nonnull public EXMLSerializeXMLDeclaration getSerializeXMLDeclaration()
getSerializeXMLDeclaration in interface IXMLWriterSettingstrue.@Nonnull public final XMLWriterSettings setSerializeXMLDeclaration(@Nonnull EXMLSerializeXMLDeclaration eSerializeXMLDecl)
eSerializeXMLDecl - XML declaration handling. May not be null.public boolean isNewLineAfterXMLDeclaration()
isNewLineAfterXMLDeclaration in interface IXMLWriterSettingstrue if a newline should be added after the XML
declaration or not. Defaults to true.@Nonnull public final XMLWriterSettings setNewLineAfterXMLDeclaration(boolean bNewLineAfterXMLDeclaration)
bNewLineAfterXMLDeclaration - true to print it, false to not print a new
line.@Nonnull public EXMLSerializeDocType getSerializeDocType()
getSerializeDocType in interface IXMLWriterSettingstrue.@Nonnull public final XMLWriterSettings setSerializeDocType(@Nonnull EXMLSerializeDocType eSerializeDocType)
eSerializeDocType - Doc type handling. May not be null.@Nonnull public EXMLSerializeComments getSerializeComments()
getSerializeComments in interface IXMLWriterSettingstrue.@Nonnull public final XMLWriterSettings setSerializeComments(@Nonnull EXMLSerializeComments eSerializeComments)
eSerializeComments - The comment handling. May not be null.@Nonnull public EXMLSerializeIndent getIndent()
getIndent in interface IXMLWriterSettingsindent and aligned.@Nonnull public final XMLWriterSettings setIndent(@Nonnull EXMLSerializeIndent eIndent)
eIndent - Indent and align definition. May not be null.@Nonnull public IXMLIndentDeterminator getIndentDeterminator()
getIndentDeterminator in interface IXMLWriterSettingsnull.@Nonnull public final XMLWriterSettings setIndentDeterminator(@Nonnull IXMLIndentDeterminator aIndentDeterminator)
aIndentDeterminator - The object to use. May not be null.@Nonnull public EXMLIncorrectCharacterHandling getIncorrectCharacterHandling()
getIncorrectCharacterHandling in interface IXMLWriterSettingsnull.@Nonnull public final XMLWriterSettings setIncorrectCharacterHandling(@Nonnull EXMLIncorrectCharacterHandling eIncorrectCharacterHandling)
eIncorrectCharacterHandling - The invalid character handling. May not be null.@Nonnull public Charset getCharset()
getCharset in interface IXMLWriterSettingsnull.@Nonnull public final XMLWriterSettings setCharset(@Nonnull Charset aCharset)
aCharset - The charset to be used. May not be null.@Nonnull public NamespaceContext getNamespaceContext()
getNamespaceContext in interface IXMLWriterSettingsnull.@Nonnull public final XMLWriterSettings setNamespaceContext(@Nullable NamespaceContext aNamespaceContext)
aNamespaceContext - The namespace context to be used. May be null.public boolean isUseDoubleQuotesForAttributes()
isUseDoubleQuotesForAttributes in interface IXMLWriterSettingstrue if attribute values should be enclosed in double
quotes, false if single quotes should be used.@Nonnull public final XMLWriterSettings setUseDoubleQuotesForAttributes(boolean bUseDoubleQuotesForAttributes)
@Nonnull public IXMLBracketModeDeterminator getBracketModeDeterminator()
getBracketModeDeterminator in interface IXMLWriterSettingsnull
.@Nonnull public final XMLWriterSettings setBracketModeDeterminator(@Nonnull IXMLBracketModeDeterminator aBracketModeDeterminator)
public boolean isSpaceOnSelfClosedElement()
IXMLWriterSettings<br />) or not (
<br/>)isSpaceOnSelfClosedElement in interface IXMLWriterSettingstrue if a space should be emitted, false
if no space should be emitted.@Nonnull public final XMLWriterSettings setSpaceOnSelfClosedElement(boolean bSpaceOnSelfClosedElement)
@Nonnull public com.helger.commons.system.ENewLineMode getNewLineMode()
getNewLineMode in interface IXMLWriterSettingsnull.@Nonnull public final XMLWriterSettings setNewLineMode(@Nonnull com.helger.commons.system.ENewLineMode eNewLineMode)
@Nonnull @Nonempty public String getIndentationString()
getIndentationString in interface IXMLWriterSettings@Nonnull public final XMLWriterSettings setIndentationString(@Nonnull @Nonempty String sIndentationString)
public boolean isEmitNamespaces()
IXMLWriterSettingsisEmitNamespaces in interface IXMLWriterSettingstrue if namespaces should be emitted,
false if all created elements should reside in the
default namespace.@Nonnull public final XMLWriterSettings setEmitNamespaces(boolean bEmitNamespaces)
public boolean isPutNamespaceContextPrefixesInRoot()
IXMLWriterSettingsIIterableNamespaceContext interface!isPutNamespaceContextPrefixesInRoot in interface IXMLWriterSettingstrue if it is enabled, false if not.@Nonnull public final XMLWriterSettings setPutNamespaceContextPrefixesInRoot(boolean bPutNamespaceContextPrefixesInRoot)
public boolean isWriteCDATAAsText()
IXMLWriterSettingsisWriteCDATAAsText in interface IXMLWriterSettingstrue if CDATA should be written as text,
false to keep CDATA as it is.@Nonnull public final XMLWriterSettings setWriteCDATAAsText(boolean bWriteCDATAAsText)
public boolean isOrderAttributesAndNamespaces()
IXMLWriterSettingsisOrderAttributesAndNamespaces in interface IXMLWriterSettingstrue to order attributes, false to keep
the original order.@Nonnull public final XMLWriterSettings setOrderAttributesAndNamespaces(boolean bOrderAttributesAndNamespaces)
@Nonnull public XMLWriterSettings getClone()
getClone in interface com.helger.commons.lang.ICloneable<XMLWriterSettings>@Nonnull @ReturnsMutableCopy public static XMLWriterSettings createForHTML4()
@Nonnull @ReturnsMutableCopy public static XMLWriterSettings createForXHTML()
@Nonnull @ReturnsMutableCopy public static XMLWriterSettings createForHTML5()
@Nonnull @ReturnsMutableCopy public static XMLWriterSettings createForCanonicalization()
XMLWriterSettings for canonicalizationCopyright © 2014–2023 Philip Helger. All rights reserved.