Package com.ctc.wstx.api
Class WriterConfig
- java.lang.Object
-
- com.ctc.wstx.api.CommonConfig
-
- com.ctc.wstx.api.WriterConfig
-
- All Implemented Interfaces:
OutputConfigFlags
,org.codehaus.stax2.XMLStreamProperties
public final class WriterConfig extends CommonConfig implements OutputConfigFlags
Simple configuration container class; passed by writer factory to writer instance created.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static boolean
DEFAULT_ADD_SPACE_AFTER_EMPTY_ELEM
09-Aug-2007, TSa: Space has always been added after empty element (before closing "/>"), but now it is configurable.protected static java.lang.String
DEFAULT_AUTOMATIC_NS_PREFIX
(package private) static boolean
DEFAULT_COPY_DEFAULT_ATTRS
(package private) static boolean
DEFAULT_ESCAPE_CR
(package private) static boolean
DEFAULT_FIX_CONTENT
As per [WSTX-120], default was changed to false, from true (default prior to wstx 4.0)(package private) static int
DEFAULT_FLAGS_FULL
For now, full instances start with same settings as J2ME subset(package private) static int
DEFAULT_FLAGS_J2ME
Default config flags are converted from individual settings, to conform to Stax 1.0 specifications.(package private) static boolean
DEFAULT_OUTPUT_CDATA_AS_TEXT
(package private) static boolean
DEFAULT_USE_DOUBLE_QUOTES_IN_XML_DECL
(package private) static boolean
DEFAULT_VALIDATE_ATTR
(package private) static boolean
DEFAULT_VALIDATE_CONTENT
(package private) static boolean
DEFAULT_VALIDATE_NAMES
(package private) static boolean
DEFAULT_VALIDATE_STRUCTURE
protected int
mConfigFlags
(package private) BufferRecycler
mCurrRecycler
This is the actually container of the recyclable buffers.(package private) boolean
mIsJ2MESubset
(package private) static java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>>
mRecyclerRef
ThisThreadLocal
contains aSoftRerefence
to aBufferRecycler
used to provide a low-cost buffer recycling between Reader instances.(package private) java.lang.Object[]
mSpecialProperties
(package private) static int
PROP_ADD_SPACE_AFTER_EMPTY_ELEM
(package private) static int
PROP_ATTR_VALUE_ESCAPER
(package private) static int
PROP_AUTO_CLOSE_OUTPUT
(package private) static int
PROP_AUTOMATIC_EMPTY_ELEMENTS
(package private) static int
PROP_AUTOMATIC_END_ELEMENTS
(package private) static int
PROP_AUTOMATIC_NS
(package private) static int
PROP_AUTOMATIC_NS_PREFIX
(package private) static int
PROP_COPY_DEFAULT_ATTRS
(package private) static int
PROP_ENABLE_NS
(package private) static int
PROP_ESCAPE_CR
(package private) static int
PROP_FIX_CONTENT
(package private) static int
PROP_OUTPUT_CDATA_AS_TEXT
(package private) static int
PROP_OUTPUT_EMPTY_ELEMENT_HANDLER
(package private) static int
PROP_OUTPUT_INVALID_CHAR_HANDLER
(package private) static int
PROP_PROBLEM_REPORTER
(package private) static int
PROP_TEXT_ESCAPER
(package private) static int
PROP_UNDERLYING_STREAM
(package private) static int
PROP_UNDERLYING_WRITER
(package private) static int
PROP_USE_DOUBLE_QUOTES_IN_XML_DECL
(package private) static int
PROP_VALIDATE_ATTR
(package private) static int
PROP_VALIDATE_CONTENT
(package private) static int
PROP_VALIDATE_NAMES
(package private) static int
PROP_VALIDATE_STRUCTURE
private static int
SP_IX_ATTR_VALUE_ESCAPER_FACTORY
private static int
SP_IX_AUTO_NS_PREFIX
private static int
SP_IX_EMPTY_ELEMENT_HANDLER
private static int
SP_IX_INVALID_CHAR_HANDLER
private static int
SP_IX_PROBLEM_REPORTER
private static int
SP_IX_TEXT_ESCAPER_FACTORY
private static int
SPEC_PROC_COUNT
(package private) static java.util.HashMap<java.lang.String,java.lang.Integer>
sProperties
Map to use for converting from String property ids to ints described above; useful to allow use of switch later on.-
Fields inherited from class com.ctc.wstx.api.CommonConfig
CPROP_IMPL_NAME, CPROP_IMPL_VERSION, CPROP_RETURN_NULL_FOR_DEFAULT_NAMESPACE, CPROP_SUPPORT_XMLID, CPROP_SUPPORTS_XML11, IMPL_NAME, IMPL_VERSION, mReturnNullForDefaultNamespace, sStdProperties
-
Fields inherited from interface com.ctc.wstx.cfg.OutputConfigFlags
CFG_ADD_SPACE_AFTER_EMPTY_ELEM, CFG_AUTO_CLOSE_OUTPUT, CFG_AUTOMATIC_EMPTY_ELEMENTS, CFG_AUTOMATIC_END_ELEMENTS, CFG_AUTOMATIC_NS, CFG_COPY_DEFAULT_ATTRS, CFG_ENABLE_NS, CFG_ESCAPE_CR, CFG_FIX_CONTENT, CFG_OUTPUT_CDATA_AS_TEXT, CFG_USE_DOUBLE_QUOTES_IN_XML_DECL, CFG_VALIDATE_ATTR, CFG_VALIDATE_CONTENT, CFG_VALIDATE_NAMES, CFG_VALIDATE_STRUCTURE
-
-
Constructor Summary
Constructors Modifier Constructor Description private
WriterConfig(WriterConfig base, boolean j2meSubset, int flags, java.lang.Object[] specProps)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
allocFullBBuffer(int minSize)
char[]
allocFullCBuffer(int minSize)
char[]
allocMediumCBuffer(int minSize)
Method called to allocate intermediate recyclable copy buffersboolean
automaticEmptyElementsEnabled()
boolean
automaticEndElementsEnabled()
boolean
automaticNamespacesEnabled()
void
configureForRobustness()
For Woodstox, this profile enables all basic well-formedness checks, including checking for name validity, and also enables all matching "fix-me" properties (currently only content-fixing property exists).void
configureForSpeed()
For Woodstox, setting this profile disables most checks for validity; specifically anything that can have measurable performance impact.void
configureForXmlConformance()
For Woodstox, this profile enables all basic well-formedness checks, including checking for name validity.static WriterConfig
createFullDefaults()
static WriterConfig
createJ2MEDefaults()
WriterConfig
createNonShared()
private BufferRecycler
createRecycler()
void
doAddSpaceAfterEmptyElem(boolean state)
void
doAutoCloseOutput(boolean state)
void
doCopyDefaultAttrs(boolean state)
void
doEscapeCr(boolean state)
void
doFixContent(boolean state)
void
doOutputCDataAsText(boolean state)
void
doSupportNamespaces(boolean state)
void
doUseDoubleQuotesInXmlDecl(boolean state)
void
doValidateAttributes(boolean state)
void
doValidateContent(boolean state)
void
doValidateNames(boolean state)
void
doValidateStructure(boolean state)
void
enableAutomaticEmptyElements(boolean state)
void
enableAutomaticEndElements(boolean state)
void
enableAutomaticNamespaces(boolean state)
protected int
findPropertyId(java.lang.String propName)
void
freeFullBBuffer(byte[] buffer)
void
freeFullCBuffer(char[] buffer)
void
freeMediumCBuffer(char[] buffer)
org.codehaus.stax2.io.EscapingWriterFactory
getAttrValueEscaperFactory()
java.lang.String
getAutomaticNsPrefix()
int
getConfigFlags()
EmptyElementHandler
getEmptyElementHandler()
InvalidCharHandler
getInvalidCharHandler()
javax.xml.stream.XMLReporter
getProblemReporter()
java.lang.Object
getProperty(int id)
private java.lang.Object
getSpecialProperty(int ix)
org.codehaus.stax2.io.EscapingWriterFactory
getTextEscaperFactory()
private boolean
hasConfigFlag(int flag)
void
setAttrValueEscaperFactory(org.codehaus.stax2.io.EscapingWriterFactory f)
void
setAutomaticNsPrefix(java.lang.String prefix)
private void
setConfigFlag(int flag, boolean state)
void
setEmptyElementHandler(EmptyElementHandler h)
void
setInvalidCharHandler(InvalidCharHandler h)
void
setProblemReporter(javax.xml.stream.XMLReporter rep)
boolean
setProperty(java.lang.String name, int id, java.lang.Object value)
private void
setSpecialProperty(int ix, java.lang.Object value)
void
setTextEscaperFactory(org.codehaus.stax2.io.EscapingWriterFactory f)
boolean
willAddSpaceAfterEmptyElem()
boolean
willAutoCloseOutput()
boolean
willCopyDefaultAttrs()
boolean
willEscapeCr()
boolean
willFixContent()
boolean
willOutputCDataAsText()
boolean
willSupportNamespaces()
boolean
willUseDoubleQuotesInXmlDecl()
boolean
willValidateAttributes()
boolean
willValidateContent()
boolean
willValidateNames()
boolean
willValidateStructure()
-
Methods inherited from class com.ctc.wstx.api.CommonConfig
doesSupportXml11, doesSupportXmlId, findStdPropertyId, getImplName, getImplVersion, getProperty, getStdProperty, isPropertySupported, reportUnknownProperty, returnNullForDefaultNamespace, safeGetProperty, setProperty, setStdProperty
-
-
-
-
Field Detail
-
DEFAULT_AUTOMATIC_NS_PREFIX
protected static final java.lang.String DEFAULT_AUTOMATIC_NS_PREFIX
- See Also:
- Constant Field Values
-
PROP_AUTOMATIC_NS
static final int PROP_AUTOMATIC_NS
- See Also:
- Constant Field Values
-
PROP_AUTOMATIC_EMPTY_ELEMENTS
static final int PROP_AUTOMATIC_EMPTY_ELEMENTS
- See Also:
- Constant Field Values
-
PROP_AUTO_CLOSE_OUTPUT
static final int PROP_AUTO_CLOSE_OUTPUT
- See Also:
- Constant Field Values
-
PROP_ENABLE_NS
static final int PROP_ENABLE_NS
- See Also:
- Constant Field Values
-
PROP_AUTOMATIC_NS_PREFIX
static final int PROP_AUTOMATIC_NS_PREFIX
- See Also:
- Constant Field Values
-
PROP_TEXT_ESCAPER
static final int PROP_TEXT_ESCAPER
- See Also:
- Constant Field Values
-
PROP_ATTR_VALUE_ESCAPER
static final int PROP_ATTR_VALUE_ESCAPER
- See Also:
- Constant Field Values
-
PROP_PROBLEM_REPORTER
static final int PROP_PROBLEM_REPORTER
- See Also:
- Constant Field Values
-
PROP_USE_DOUBLE_QUOTES_IN_XML_DECL
static final int PROP_USE_DOUBLE_QUOTES_IN_XML_DECL
- See Also:
- Constant Field Values
-
PROP_OUTPUT_CDATA_AS_TEXT
static final int PROP_OUTPUT_CDATA_AS_TEXT
- See Also:
- Constant Field Values
-
PROP_COPY_DEFAULT_ATTRS
static final int PROP_COPY_DEFAULT_ATTRS
- See Also:
- Constant Field Values
-
PROP_ESCAPE_CR
static final int PROP_ESCAPE_CR
- See Also:
- Constant Field Values
-
PROP_ADD_SPACE_AFTER_EMPTY_ELEM
static final int PROP_ADD_SPACE_AFTER_EMPTY_ELEM
- See Also:
- Constant Field Values
-
PROP_AUTOMATIC_END_ELEMENTS
static final int PROP_AUTOMATIC_END_ELEMENTS
- See Also:
- Constant Field Values
-
PROP_VALIDATE_STRUCTURE
static final int PROP_VALIDATE_STRUCTURE
- See Also:
- Constant Field Values
-
PROP_VALIDATE_CONTENT
static final int PROP_VALIDATE_CONTENT
- See Also:
- Constant Field Values
-
PROP_VALIDATE_ATTR
static final int PROP_VALIDATE_ATTR
- See Also:
- Constant Field Values
-
PROP_VALIDATE_NAMES
static final int PROP_VALIDATE_NAMES
- See Also:
- Constant Field Values
-
PROP_FIX_CONTENT
static final int PROP_FIX_CONTENT
- See Also:
- Constant Field Values
-
PROP_OUTPUT_INVALID_CHAR_HANDLER
static final int PROP_OUTPUT_INVALID_CHAR_HANDLER
- See Also:
- Constant Field Values
-
PROP_OUTPUT_EMPTY_ELEMENT_HANDLER
static final int PROP_OUTPUT_EMPTY_ELEMENT_HANDLER
- See Also:
- Constant Field Values
-
PROP_UNDERLYING_STREAM
static final int PROP_UNDERLYING_STREAM
- See Also:
- Constant Field Values
-
PROP_UNDERLYING_WRITER
static final int PROP_UNDERLYING_WRITER
- See Also:
- Constant Field Values
-
DEFAULT_USE_DOUBLE_QUOTES_IN_XML_DECL
static final boolean DEFAULT_USE_DOUBLE_QUOTES_IN_XML_DECL
- See Also:
- Constant Field Values
-
DEFAULT_OUTPUT_CDATA_AS_TEXT
static final boolean DEFAULT_OUTPUT_CDATA_AS_TEXT
- See Also:
- Constant Field Values
-
DEFAULT_COPY_DEFAULT_ATTRS
static final boolean DEFAULT_COPY_DEFAULT_ATTRS
- See Also:
- Constant Field Values
-
DEFAULT_ESCAPE_CR
static final boolean DEFAULT_ESCAPE_CR
- See Also:
- Constant Field Values
-
DEFAULT_ADD_SPACE_AFTER_EMPTY_ELEM
static final boolean DEFAULT_ADD_SPACE_AFTER_EMPTY_ELEM
09-Aug-2007, TSa: Space has always been added after empty element (before closing "/>"), but now it is configurable. 31-Dec-2009, TSa: Intention was to leave it enabled for backwards compatibility: but due to a bug this was NOT the case... ugh.- See Also:
- Constant Field Values
-
DEFAULT_VALIDATE_STRUCTURE
static final boolean DEFAULT_VALIDATE_STRUCTURE
- See Also:
- Constant Field Values
-
DEFAULT_VALIDATE_CONTENT
static final boolean DEFAULT_VALIDATE_CONTENT
- See Also:
- Constant Field Values
-
DEFAULT_VALIDATE_ATTR
static final boolean DEFAULT_VALIDATE_ATTR
- See Also:
- Constant Field Values
-
DEFAULT_VALIDATE_NAMES
static final boolean DEFAULT_VALIDATE_NAMES
- See Also:
- Constant Field Values
-
DEFAULT_FIX_CONTENT
static final boolean DEFAULT_FIX_CONTENT
As per [WSTX-120], default was changed to false, from true (default prior to wstx 4.0)- See Also:
- Constant Field Values
-
DEFAULT_FLAGS_J2ME
static final int DEFAULT_FLAGS_J2ME
Default config flags are converted from individual settings, to conform to Stax 1.0 specifications.- See Also:
- Constant Field Values
-
DEFAULT_FLAGS_FULL
static final int DEFAULT_FLAGS_FULL
For now, full instances start with same settings as J2ME subset- See Also:
- Constant Field Values
-
sProperties
static final java.util.HashMap<java.lang.String,java.lang.Integer> sProperties
Map to use for converting from String property ids to ints described above; useful to allow use of switch later on.
-
mIsJ2MESubset
final boolean mIsJ2MESubset
-
mConfigFlags
protected int mConfigFlags
-
mSpecialProperties
java.lang.Object[] mSpecialProperties
-
SPEC_PROC_COUNT
private static final int SPEC_PROC_COUNT
- See Also:
- Constant Field Values
-
SP_IX_AUTO_NS_PREFIX
private static final int SP_IX_AUTO_NS_PREFIX
- See Also:
- Constant Field Values
-
SP_IX_TEXT_ESCAPER_FACTORY
private static final int SP_IX_TEXT_ESCAPER_FACTORY
- See Also:
- Constant Field Values
-
SP_IX_ATTR_VALUE_ESCAPER_FACTORY
private static final int SP_IX_ATTR_VALUE_ESCAPER_FACTORY
- See Also:
- Constant Field Values
-
SP_IX_PROBLEM_REPORTER
private static final int SP_IX_PROBLEM_REPORTER
- See Also:
- Constant Field Values
-
SP_IX_INVALID_CHAR_HANDLER
private static final int SP_IX_INVALID_CHAR_HANDLER
- See Also:
- Constant Field Values
-
SP_IX_EMPTY_ELEMENT_HANDLER
private static final int SP_IX_EMPTY_ELEMENT_HANDLER
- See Also:
- Constant Field Values
-
mRecyclerRef
static final java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>> mRecyclerRef
ThisThreadLocal
contains aSoftRerefence
to aBufferRecycler
used to provide a low-cost buffer recycling between Reader instances.
-
mCurrRecycler
BufferRecycler mCurrRecycler
This is the actually container of the recyclable buffers. It is obtained via ThreadLocal/SoftReference combination, if one exists, when Config instance is created. If one does not exists, it will created first time a buffer is returned.
-
-
Constructor Detail
-
WriterConfig
private WriterConfig(WriterConfig base, boolean j2meSubset, int flags, java.lang.Object[] specProps)
-
-
Method Detail
-
createJ2MEDefaults
public static WriterConfig createJ2MEDefaults()
-
createFullDefaults
public static WriterConfig createFullDefaults()
-
createNonShared
public WriterConfig createNonShared()
-
findPropertyId
protected int findPropertyId(java.lang.String propName)
- Specified by:
findPropertyId
in classCommonConfig
- Returns:
- Internal enumerated int matching the String name of the property, if one found: -1 to indicate no match was found.
-
getProperty
public java.lang.Object getProperty(int id)
- Specified by:
getProperty
in classCommonConfig
-
setProperty
public boolean setProperty(java.lang.String name, int id, java.lang.Object value)
- Specified by:
setProperty
in classCommonConfig
- Returns:
- True, if the specified property was succesfully set to specified value; false if its value was not changed
-
getConfigFlags
public int getConfigFlags()
-
automaticNamespacesEnabled
public boolean automaticNamespacesEnabled()
-
automaticEmptyElementsEnabled
public boolean automaticEmptyElementsEnabled()
-
willAutoCloseOutput
public boolean willAutoCloseOutput()
-
willSupportNamespaces
public boolean willSupportNamespaces()
-
willUseDoubleQuotesInXmlDecl
public boolean willUseDoubleQuotesInXmlDecl()
- Since:
- 4.2.2
-
willOutputCDataAsText
public boolean willOutputCDataAsText()
-
willCopyDefaultAttrs
public boolean willCopyDefaultAttrs()
-
willEscapeCr
public boolean willEscapeCr()
-
willAddSpaceAfterEmptyElem
public boolean willAddSpaceAfterEmptyElem()
-
automaticEndElementsEnabled
public boolean automaticEndElementsEnabled()
-
willValidateStructure
public boolean willValidateStructure()
-
willValidateContent
public boolean willValidateContent()
-
willValidateAttributes
public boolean willValidateAttributes()
-
willValidateNames
public boolean willValidateNames()
-
willFixContent
public boolean willFixContent()
-
getAutomaticNsPrefix
public java.lang.String getAutomaticNsPrefix()
- Returns:
- Prefix to use as the base for automatically generated namespace prefixes ("namespace prefix prefix", so to speak). Defaults to "wstxns".
-
getTextEscaperFactory
public org.codehaus.stax2.io.EscapingWriterFactory getTextEscaperFactory()
-
getAttrValueEscaperFactory
public org.codehaus.stax2.io.EscapingWriterFactory getAttrValueEscaperFactory()
-
getProblemReporter
public javax.xml.stream.XMLReporter getProblemReporter()
-
getInvalidCharHandler
public InvalidCharHandler getInvalidCharHandler()
-
getEmptyElementHandler
public EmptyElementHandler getEmptyElementHandler()
-
enableAutomaticNamespaces
public void enableAutomaticNamespaces(boolean state)
-
enableAutomaticEmptyElements
public void enableAutomaticEmptyElements(boolean state)
-
doAutoCloseOutput
public void doAutoCloseOutput(boolean state)
-
doSupportNamespaces
public void doSupportNamespaces(boolean state)
-
doUseDoubleQuotesInXmlDecl
public void doUseDoubleQuotesInXmlDecl(boolean state)
- Since:
- 4.2.2
-
doOutputCDataAsText
public void doOutputCDataAsText(boolean state)
-
doCopyDefaultAttrs
public void doCopyDefaultAttrs(boolean state)
-
doEscapeCr
public void doEscapeCr(boolean state)
-
doAddSpaceAfterEmptyElem
public void doAddSpaceAfterEmptyElem(boolean state)
-
enableAutomaticEndElements
public void enableAutomaticEndElements(boolean state)
-
doValidateStructure
public void doValidateStructure(boolean state)
-
doValidateContent
public void doValidateContent(boolean state)
-
doValidateAttributes
public void doValidateAttributes(boolean state)
-
doValidateNames
public void doValidateNames(boolean state)
-
doFixContent
public void doFixContent(boolean state)
-
setAutomaticNsPrefix
public void setAutomaticNsPrefix(java.lang.String prefix)
- Parameters:
prefix
- Prefix to use as the base for automatically generated namespace prefixes ("namespace prefix prefix", so to speak).
-
setTextEscaperFactory
public void setTextEscaperFactory(org.codehaus.stax2.io.EscapingWriterFactory f)
-
setAttrValueEscaperFactory
public void setAttrValueEscaperFactory(org.codehaus.stax2.io.EscapingWriterFactory f)
-
setProblemReporter
public void setProblemReporter(javax.xml.stream.XMLReporter rep)
-
setInvalidCharHandler
public void setInvalidCharHandler(InvalidCharHandler h)
-
setEmptyElementHandler
public void setEmptyElementHandler(EmptyElementHandler h)
-
configureForXmlConformance
public void configureForXmlConformance()
For Woodstox, this profile enables all basic well-formedness checks, including checking for name validity.
-
configureForRobustness
public void configureForRobustness()
For Woodstox, this profile enables all basic well-formedness checks, including checking for name validity, and also enables all matching "fix-me" properties (currently only content-fixing property exists).
-
configureForSpeed
public void configureForSpeed()
For Woodstox, setting this profile disables most checks for validity; specifically anything that can have measurable performance impact.
-
allocMediumCBuffer
public char[] allocMediumCBuffer(int minSize)
Method called to allocate intermediate recyclable copy buffers
-
freeMediumCBuffer
public void freeMediumCBuffer(char[] buffer)
-
allocFullCBuffer
public char[] allocFullCBuffer(int minSize)
-
freeFullCBuffer
public void freeFullCBuffer(char[] buffer)
-
allocFullBBuffer
public byte[] allocFullBBuffer(int minSize)
-
freeFullBBuffer
public void freeFullBBuffer(byte[] buffer)
-
createRecycler
private BufferRecycler createRecycler()
-
setConfigFlag
private void setConfigFlag(int flag, boolean state)
-
hasConfigFlag
private final boolean hasConfigFlag(int flag)
-
getSpecialProperty
private final java.lang.Object getSpecialProperty(int ix)
-
setSpecialProperty
private final void setSpecialProperty(int ix, java.lang.Object value)
-
-