Package com.ctc.wstx.sw
Class BaseStreamWriter
- java.lang.Object
-
- org.codehaus.stax2.ri.Stax2WriterImpl
-
- com.ctc.wstx.sw.BaseStreamWriter
-
- All Implemented Interfaces:
OutputConfigFlags
,XMLStreamConstants
,XMLStreamWriter
,org.codehaus.stax2.typed.TypedXMLStreamWriter
,org.codehaus.stax2.validation.Validatable
,org.codehaus.stax2.validation.ValidationContext
,org.codehaus.stax2.XMLStreamWriter2
- Direct Known Subclasses:
TypedStreamWriter
public abstract class BaseStreamWriter extends org.codehaus.stax2.ri.Stax2WriterImpl implements org.codehaus.stax2.validation.ValidationContext, OutputConfigFlags
Base class forXMLStreamWriter
implementations Woodstox has. Contains partial stream writer implementation, plus utility methods shared by concrete implementation classes. Main reason for such abstract base class is to allow other parts of Woodstox core to refer to any of stream writer implementations in general way.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
ATTR_MIN_ARRAYCOPY
protected static char
CHAR_SPACE
protected static int
DEFAULT_COPYBUFFER_LEN
protected boolean
mAnyOutput
Flag that is set to true first time something has been output.protected boolean
mCfgAutomaticEmptyElems
protected boolean
mCfgCDataAsText
protected boolean
mCfgCopyDefaultAttrs
protected boolean
mCheckAttrs
protected boolean
mCheckStructure
protected WriterConfig
mConfig
protected char[]
mCopyBuffer
Intermediate buffer into which characters of a String can be copied, in cases where such a copy followed by array access is faster than callingString.charAt()
(which perhaps surprisingly is often case, and especially significant for longer buffers).protected String
mDtdRootElem
Value passed as the expected root element, when using the multiple argumentwriteDTD(java.lang.String)
method.protected boolean
mEmptyElement
Flag that indicates that current element is an empty element (one that is explicitly defined as one, by calling a method -- NOT one that just happens to be empty).protected String
mEncoding
Encoding to use; may be passed from the factory (when a method that defines encoding is used), updated by a call towriteStartDocument()
, or null if neither.protected static int
MIN_ARRAYCOPY
This constant defines minimum length of a String, for which it is beneficial to do an intermediate copy (using String.getChars()), and iterate over intermediate array, instead of iterating using String.charAt().protected boolean
mReturnNullForDefaultNamespace
protected boolean
mStartElementOpen
Flag that is set during time that a start element is "open", ie.protected int
mState
protected org.codehaus.stax2.validation.XMLValidator
mValidator
Optional validator to use for validating output against one or more schemas, and/or for safe pretty-printing (indentation).protected int
mVldContent
State value used with validation, to track types of content that is allowed at this point in output stream.protected org.codehaus.stax2.validation.ValidationProblemHandler
mVldProbHandler
Custom validation problem handler, if any.protected XmlWriter
mWriter
Actual physical writer to output serialized XML content toprotected boolean
mXml11
Since XML 1.1 has some differences to 1.0, we need to keep a flag to indicate if we were to output XML 1.1 document.protected static int
STATE_EPILOG
protected static int
STATE_PROLOG
protected static int
STATE_TREE
-
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
-
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseStreamWriter(XmlWriter xw, String enc, WriterConfig cfg)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
addDefaultAttribute(String localName, String uri, String prefix, String value)
Adding default attribute values does not usually make sense on output side, so the implementation is a NOP for now.void
close()
void
closeCompletely()
protected abstract void
closeStartElement(boolean emptyElem)
Method called to close an open start element, when another main-level element (not namespace declaration or attribute) is being output; except for end element which is handled differently.void
copyEventFromReader(org.codehaus.stax2.XMLStreamReader2 sr, boolean preserveEventData)
Method that essentially copies event that the specified reader has just read.abstract void
copyStartElement(InputElementStack elemStack, AttributeCollector attrCollector)
Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points toprotected void
doReportProblem(XMLReporter rep, String probType, String msg, Location loc)
protected void
doReportProblem(XMLReporter rep, org.codehaus.stax2.validation.XMLValidationProblem prob)
protected void
doWriteStartDocument(String version, String encoding, String standAlone)
int
findAttributeIndex(String nsURI, String localName)
void
flush()
int
getAttributeCount()
String
getAttributeLocalName(int index)
String
getAttributeNamespace(int index)
String
getAttributePrefix(int index)
String
getAttributeType(int index)
String
getAttributeValue(int index)
String
getAttributeValue(String nsURI, String localName)
String
getBaseUri()
As of now, there is no way to specify the base URI.protected char[]
getCopyBuffer()
protected char[]
getCopyBuffer(int minLen)
abstract QName
getCurrentElementName()
String
getEncoding()
org.codehaus.stax2.XMLStreamLocation2
getLocation()
abstract NamespaceContext
getNamespaceContext()
abstract String
getNamespaceURI(String prefix)
abstract String
getPrefix(String uri)
Object
getProperty(String name)
protected abstract String
getTopElementDesc()
Method needed for error message generationLocation
getValidationLocation()
String
getXmlVersion()
protected boolean
inPrologOrEpilog()
boolean
isNotationDeclared(String name)
boolean
isPropertySupported(String name)
boolean
isUnparsedEntityDeclared(String name)
protected boolean
isValidating()
Method that is used by output classes to determine whether we are in validating mode.protected static void
reportIllegalArg(String msg)
protected static void
reportIllegalMethod(String msg)
Method called when an illegal method (namespace-specific method on non-ns writer) is called by the application.protected void
reportInvalidContent(int evtType)
protected static void
reportNwfAttr(String msg)
This is the method called when an output method call violates attribute well-formedness checks (trying to output dup attrs) andWstxOutputProperties.P_OUTPUT_VALIDATE_NAMES
is is enabled.protected static void
reportNwfAttr(String msg, Object arg)
protected static void
reportNwfContent(String msg)
This is the method called when an output method call violates content well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT
is is enabled.protected static void
reportNwfContent(String msg, Object arg)
protected static void
reportNwfStructure(String msg)
This is the method called when an output method call violates structural well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE
is is enabled.protected static void
reportNwfStructure(String msg, Object arg)
void
reportProblem(org.codehaus.stax2.validation.XMLValidationProblem prob)
void
reportValidationProblem(String msg)
void
reportValidationProblem(String msg, int severity)
void
reportValidationProblem(String format, Object arg)
void
reportValidationProblem(String format, Object arg, Object arg2)
void
reportValidationProblem(String msg, Location loc, int severity)
void
reportValidationProblem(Location loc, String msg)
abstract void
setDefaultNamespace(String uri)
abstract void
setNamespaceContext(NamespaceContext context)
abstract void
setPrefix(String prefix, String uri)
boolean
setProperty(String name, Object value)
org.codehaus.stax2.validation.ValidationProblemHandler
setValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler h)
org.codehaus.stax2.validation.XMLValidator
stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema)
org.codehaus.stax2.validation.XMLValidator
stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidator validator)
protected static void
throwFromIOE(IOException ioe)
protected static void
throwOutputError(String msg)
protected static void
throwOutputError(String format, Object arg)
String
toString()
org.codehaus.stax2.validation.XMLValidator
validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema)
abstract String
validateQNamePrefix(QName name)
Method called before writing a QName via Typed Access API.protected void
verifyRootElement(String localName, String prefix)
protected void
verifyWriteCData()
protected void
verifyWriteDTD()
Writer
wrapAsRawWriter()
Method that can be called to get a wrapper instance that can be used to essentially call thewriteRaw
method via regularWriter
interface.Writer
wrapAsTextWriter()
Method that can be called to get a wrapper instance that can be used to essentially call thewriteCharacters
method via regularWriter
interface.abstract void
writeAttribute(String localName, String value)
abstract void
writeAttribute(String nsURI, String localName, String value)
abstract void
writeAttribute(String prefix, String nsURI, String localName, String value)
void
writeCData(char[] cbuf, int start, int len)
void
writeCData(String data)
void
writeCharacters(char[] text, int start, int len)
void
writeCharacters(String text)
void
writeCharacters(Characters ch)
Method called byXMLEventWriter
(instead of more generic text output methods), so that we can verify (if necessary) that this character output type is legal in this context.void
writeComment(String data)
abstract void
writeDefaultNamespace(String nsURI)
void
writeDTD(String dtd)
void
writeDTD(String rootName, String systemId, String publicId, String internalSubset)
void
writeDTD(org.codehaus.stax2.DTDInfo info)
abstract void
writeEmptyElement(String localName)
abstract void
writeEmptyElement(String nsURI, String localName)
abstract void
writeEmptyElement(String prefix, String localName, String nsURI)
void
writeEndDocument()
abstract void
writeEndElement()
abstract void
writeEndElement(QName name)
Method called byXMLEventWriter
(instead of the version that takes no argument), so that we can verify it does match the start element if necessary.void
writeEntityRef(String name)
abstract void
writeFullEndElement()
abstract void
writeNamespace(String prefix, String nsURI)
void
writeProcessingInstruction(String target)
void
writeProcessingInstruction(String target, String data)
void
writeRaw(char[] text, int start, int offset)
void
writeRaw(String text)
void
writeRaw(String text, int start, int offset)
void
writeSpace(char[] text, int offset, int length)
void
writeSpace(String text)
void
writeStartDocument()
void
writeStartDocument(String version)
void
writeStartDocument(String encoding, String version)
void
writeStartDocument(String version, String encoding, boolean standAlone)
abstract void
writeStartElement(String localName)
abstract void
writeStartElement(String nsURI, String localName)
abstract void
writeStartElement(String prefix, String localName, String nsURI)
abstract void
writeStartElement(StartElement elem)
Convenience method needed byXMLEventWriter
implementation, to use when writing a start element, and possibly its attributes and namespace declarations.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.codehaus.stax2.typed.TypedXMLStreamWriter
writeBinary, writeBinary, writeBinaryAttribute, writeBinaryAttribute, writeBoolean, writeBooleanAttribute, writeDecimal, writeDecimalAttribute, writeDouble, writeDoubleArray, writeDoubleArrayAttribute, writeDoubleAttribute, writeFloat, writeFloatArray, writeFloatArrayAttribute, writeFloatAttribute, writeInt, writeIntArray, writeIntArrayAttribute, writeIntAttribute, writeInteger, writeIntegerAttribute, writeLong, writeLongArray, writeLongArrayAttribute, writeLongAttribute, writeQName, writeQNameAttribute
-
-
-
-
Field Detail
-
STATE_PROLOG
protected static final int STATE_PROLOG
- See Also:
- Constant Field Values
-
STATE_TREE
protected static final int STATE_TREE
- See Also:
- Constant Field Values
-
STATE_EPILOG
protected static final int STATE_EPILOG
- See Also:
- Constant Field Values
-
CHAR_SPACE
protected static final char CHAR_SPACE
- See Also:
- Constant Field Values
-
MIN_ARRAYCOPY
protected static final int MIN_ARRAYCOPY
This constant defines minimum length of a String, for which it is beneficial to do an intermediate copy (using String.getChars()), and iterate over intermediate array, instead of iterating using String.charAt(). Former is generally faster for longer Strings, but has some overhead for shorter Strings. Tests indicate that the threshold is somewhere between 8 and 16 characters, at least on x86 platform.- See Also:
- Constant Field Values
-
ATTR_MIN_ARRAYCOPY
protected static final int ATTR_MIN_ARRAYCOPY
- See Also:
- Constant Field Values
-
DEFAULT_COPYBUFFER_LEN
protected static final int DEFAULT_COPYBUFFER_LEN
- See Also:
- Constant Field Values
-
mWriter
protected final XmlWriter mWriter
Actual physical writer to output serialized XML content to
-
mCopyBuffer
protected char[] mCopyBuffer
Intermediate buffer into which characters of a String can be copied, in cases where such a copy followed by array access is faster than callingString.charAt()
(which perhaps surprisingly is often case, and especially significant for longer buffers).
-
mConfig
protected final WriterConfig mConfig
-
mCfgCDataAsText
protected final boolean mCfgCDataAsText
-
mCfgCopyDefaultAttrs
protected final boolean mCfgCopyDefaultAttrs
-
mCfgAutomaticEmptyElems
protected final boolean mCfgAutomaticEmptyElems
-
mCheckStructure
protected boolean mCheckStructure
-
mCheckAttrs
protected boolean mCheckAttrs
-
mEncoding
protected String mEncoding
Encoding to use; may be passed from the factory (when a method that defines encoding is used), updated by a call towriteStartDocument()
, or null if neither. Is passed to the escaping writer factory to allow escaping writers to do additional escaping if necessary (like encapsulating non-ascii chars in a doc encoded usig ascii).
-
mValidator
protected org.codehaus.stax2.validation.XMLValidator mValidator
Optional validator to use for validating output against one or more schemas, and/or for safe pretty-printing (indentation).
-
mXml11
protected boolean mXml11
Since XML 1.1 has some differences to 1.0, we need to keep a flag to indicate if we were to output XML 1.1 document.
-
mVldProbHandler
protected org.codehaus.stax2.validation.ValidationProblemHandler mVldProbHandler
Custom validation problem handler, if any.
-
mState
protected int mState
-
mAnyOutput
protected boolean mAnyOutput
Flag that is set to true first time something has been output. Generally needed to keep track of whether XML declaration (START_DOCUMENT) can be output or not.
-
mStartElementOpen
protected boolean mStartElementOpen
Flag that is set during time that a start element is "open", ie. START_ELEMENT has been output (and possibly zero or more name space declarations and attributes), before other main-level constructs have been output.
-
mEmptyElement
protected boolean mEmptyElement
Flag that indicates that current element is an empty element (one that is explicitly defined as one, by calling a method -- NOT one that just happens to be empty). This is needed to know what to do when next non-ns/attr node is output; normally a new context is opened, but for empty elements not.
-
mVldContent
protected int mVldContent
State value used with validation, to track types of content that is allowed at this point in output stream. Only used if validation is enabled: if so, value is determined via validation callbacks.
-
mDtdRootElem
protected String mDtdRootElem
Value passed as the expected root element, when using the multiple argumentwriteDTD(java.lang.String)
method. Will be used in structurally validating mode (and in dtd-validating mode, since that automatically enables structural validation as well, to pre-filter well-formedness errors that validators might have trouble dealing with).
-
mReturnNullForDefaultNamespace
protected boolean mReturnNullForDefaultNamespace
-
-
Constructor Detail
-
BaseStreamWriter
protected BaseStreamWriter(XmlWriter xw, String enc, WriterConfig cfg)
-
-
Method Detail
-
close
public void close() throws XMLStreamException
- Specified by:
close
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
flush
public void flush() throws XMLStreamException
- Specified by:
flush
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
getNamespaceContext
public abstract NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContext
in interfaceXMLStreamWriter
-
getPrefix
public abstract String getPrefix(String uri)
- Specified by:
getPrefix
in interfaceXMLStreamWriter
-
getProperty
public Object getProperty(String name)
- Specified by:
getProperty
in interfaceXMLStreamWriter
-
setDefaultNamespace
public abstract void setDefaultNamespace(String uri) throws XMLStreamException
- Specified by:
setDefaultNamespace
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
setNamespaceContext
public abstract void setNamespaceContext(NamespaceContext context) throws XMLStreamException
- Specified by:
setNamespaceContext
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
setPrefix
public abstract void setPrefix(String prefix, String uri) throws XMLStreamException
- Specified by:
setPrefix
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(String localName, String value) throws XMLStreamException
- Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(String nsURI, String localName, String value) throws XMLStreamException
- Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(String prefix, String nsURI, String localName, String value) throws XMLStreamException
- Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeCData
public void writeCData(String data) throws XMLStreamException
- Specified by:
writeCData
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException
- Specified by:
writeCharacters
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(String text) throws XMLStreamException
- Specified by:
writeCharacters
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeComment
public void writeComment(String data) throws XMLStreamException
- Specified by:
writeComment
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeDefaultNamespace
public abstract void writeDefaultNamespace(String nsURI) throws XMLStreamException
- Specified by:
writeDefaultNamespace
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeDTD
public void writeDTD(String dtd) throws XMLStreamException
- Specified by:
writeDTD
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(String localName) throws XMLStreamException
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(String nsURI, String localName) throws XMLStreamException
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(String prefix, String localName, String nsURI) throws XMLStreamException
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEndDocument
public void writeEndDocument() throws XMLStreamException
- Specified by:
writeEndDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEndElement
public abstract void writeEndElement() throws XMLStreamException
- Specified by:
writeEndElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeEntityRef
public void writeEntityRef(String name) throws XMLStreamException
- Specified by:
writeEntityRef
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeNamespace
public abstract void writeNamespace(String prefix, String nsURI) throws XMLStreamException
- Specified by:
writeNamespace
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String target) throws XMLStreamException
- Specified by:
writeProcessingInstruction
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String target, String data) throws XMLStreamException
- Specified by:
writeProcessingInstruction
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws XMLStreamException
- Specified by:
writeStartDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String version) throws XMLStreamException
- Specified by:
writeStartDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String encoding, String version) throws XMLStreamException
- Specified by:
writeStartDocument
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
doWriteStartDocument
protected void doWriteStartDocument(String version, String encoding, String standAlone) throws XMLStreamException
- Throws:
XMLStreamException
-
writeStartElement
public abstract void writeStartElement(String localName) throws XMLStreamException
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartElement
public abstract void writeStartElement(String nsURI, String localName) throws XMLStreamException
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
writeStartElement
public abstract void writeStartElement(String prefix, String localName, String nsURI) throws XMLStreamException
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Throws:
XMLStreamException
-
copyEventFromReader
public void copyEventFromReader(org.codehaus.stax2.XMLStreamReader2 sr, boolean preserveEventData) throws XMLStreamException
Method that essentially copies event that the specified reader has just read.- Specified by:
copyEventFromReader
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
copyEventFromReader
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Parameters:
sr
- Stream reader to use for accessing event to copypreserveEventData
- If true, writer is not allowed to change the state of the reader (so that all the data associated with the current event has to be preserved); if false, writer is allowed to use methods that may cause some data to be discarded. Setting this to false may improve the performance, since it may allow full no-copy streaming of data, especially textual contents.- Throws:
XMLStreamException
-
closeCompletely
public void closeCompletely() throws XMLStreamException
- Specified by:
closeCompletely
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Throws:
XMLStreamException
-
isPropertySupported
public boolean isPropertySupported(String name)
- Specified by:
isPropertySupported
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
isPropertySupported
in classorg.codehaus.stax2.ri.Stax2WriterImpl
-
setProperty
public boolean setProperty(String name, Object value)
- Specified by:
setProperty
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
setProperty
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Parameters:
name
- Name of the property to setvalue
- Value to set property to.- Returns:
- True, if the specified property was succesfully set to specified value; false if its value was not changed
-
validateAgainst
public org.codehaus.stax2.validation.XMLValidator validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema) throws XMLStreamException
- Specified by:
validateAgainst
in interfaceorg.codehaus.stax2.validation.Validatable
- Overrides:
validateAgainst
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema) throws XMLStreamException
- Specified by:
stopValidatingAgainst
in interfaceorg.codehaus.stax2.validation.Validatable
- Overrides:
stopValidatingAgainst
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidator validator) throws XMLStreamException
- Specified by:
stopValidatingAgainst
in interfaceorg.codehaus.stax2.validation.Validatable
- Overrides:
stopValidatingAgainst
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
setValidationProblemHandler
public org.codehaus.stax2.validation.ValidationProblemHandler setValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler h)
- Specified by:
setValidationProblemHandler
in interfaceorg.codehaus.stax2.validation.Validatable
- Overrides:
setValidationProblemHandler
in classorg.codehaus.stax2.ri.Stax2WriterImpl
-
getLocation
public org.codehaus.stax2.XMLStreamLocation2 getLocation()
- Specified by:
getLocation
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Specified by:
getLocation
in classorg.codehaus.stax2.ri.Stax2WriterImpl
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Specified by:
getEncoding
in classorg.codehaus.stax2.ri.Stax2WriterImpl
-
writeCData
public void writeCData(char[] cbuf, int start, int len) throws XMLStreamException
- Specified by:
writeCData
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
writeCData
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeDTD
public void writeDTD(org.codehaus.stax2.DTDInfo info) throws XMLStreamException
- Throws:
XMLStreamException
-
writeDTD
public void writeDTD(String rootName, String systemId, String publicId, String internalSubset) throws XMLStreamException
- Specified by:
writeDTD
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
writeDTD
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeFullEndElement
public abstract void writeFullEndElement() throws XMLStreamException
- Specified by:
writeFullEndElement
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
writeFullEndElement
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String version, String encoding, boolean standAlone) throws XMLStreamException
- Specified by:
writeStartDocument
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Specified by:
writeStartDocument
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeRaw
public void writeRaw(String text) throws XMLStreamException
- Specified by:
writeRaw
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
writeRaw
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeRaw
public void writeRaw(String text, int start, int offset) throws XMLStreamException
- Specified by:
writeRaw
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Specified by:
writeRaw
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeRaw
public void writeRaw(char[] text, int start, int offset) throws XMLStreamException
- Specified by:
writeRaw
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Specified by:
writeRaw
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeSpace
public void writeSpace(String text) throws XMLStreamException
- Specified by:
writeSpace
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
writeSpace
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
writeSpace
public void writeSpace(char[] text, int offset, int length) throws XMLStreamException
- Specified by:
writeSpace
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Overrides:
writeSpace
in classorg.codehaus.stax2.ri.Stax2WriterImpl
- Throws:
XMLStreamException
-
getXmlVersion
public String getXmlVersion()
- Specified by:
getXmlVersion
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getCurrentElementName
public abstract QName getCurrentElementName()
- Specified by:
getCurrentElementName
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getNamespaceURI
public abstract String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURI
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getBaseUri
public String getBaseUri()
As of now, there is no way to specify the base URI. Could be improved in future, if xml:base is supported.- Specified by:
getBaseUri
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getValidationLocation
public Location getValidationLocation()
- Specified by:
getValidationLocation
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
reportProblem
public void reportProblem(org.codehaus.stax2.validation.XMLValidationProblem prob) throws XMLStreamException
- Specified by:
reportProblem
in interfaceorg.codehaus.stax2.validation.ValidationContext
- Throws:
XMLStreamException
-
addDefaultAttribute
public int addDefaultAttribute(String localName, String uri, String prefix, String value)
Adding default attribute values does not usually make sense on output side, so the implementation is a NOP for now.- Specified by:
addDefaultAttribute
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
isNotationDeclared
public boolean isNotationDeclared(String name)
- Specified by:
isNotationDeclared
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
isUnparsedEntityDeclared
public boolean isUnparsedEntityDeclared(String name)
- Specified by:
isUnparsedEntityDeclared
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCount
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeLocalName
public String getAttributeLocalName(int index)
- Specified by:
getAttributeLocalName
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeNamespace
public String getAttributeNamespace(int index)
- Specified by:
getAttributeNamespace
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributePrefix
public String getAttributePrefix(int index)
- Specified by:
getAttributePrefix
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeValue
public String getAttributeValue(int index)
- Specified by:
getAttributeValue
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeValue
public String getAttributeValue(String nsURI, String localName)
- Specified by:
getAttributeValue
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeType
public String getAttributeType(int index)
- Specified by:
getAttributeType
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
findAttributeIndex
public int findAttributeIndex(String nsURI, String localName)
- Specified by:
findAttributeIndex
in interfaceorg.codehaus.stax2.validation.ValidationContext
-
wrapAsRawWriter
public final Writer wrapAsRawWriter()
Method that can be called to get a wrapper instance that can be used to essentially call thewriteRaw
method via regularWriter
interface.
-
wrapAsTextWriter
public final Writer wrapAsTextWriter()
Method that can be called to get a wrapper instance that can be used to essentially call thewriteCharacters
method via regularWriter
interface.
-
isValidating
protected boolean isValidating()
Method that is used by output classes to determine whether we are in validating mode.Note: current implementation of this method is not perfect; it may be possible it can return true even if we are only using a DTD to get some limited info, without validating?
-
writeStartElement
public abstract void writeStartElement(StartElement elem) throws XMLStreamException
Convenience method needed byXMLEventWriter
implementation, to use when writing a start element, and possibly its attributes and namespace declarations.- Throws:
XMLStreamException
-
writeEndElement
public abstract void writeEndElement(QName name) throws XMLStreamException
Method called byXMLEventWriter
(instead of the version that takes no argument), so that we can verify it does match the start element if necessary.- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(Characters ch) throws XMLStreamException
Method called byXMLEventWriter
(instead of more generic text output methods), so that we can verify (if necessary) that this character output type is legal in this context. Specifically, it's not acceptable to add non-whitespace content outside root element (in prolog/epilog).Note: cut'n pasted from the main
writeCharacters
; not good... but done to optimize white-space cases.- Throws:
XMLStreamException
-
closeStartElement
protected abstract void closeStartElement(boolean emptyElem) throws XMLStreamException
Method called to close an open start element, when another main-level element (not namespace declaration or attribute) is being output; except for end element which is handled differently.- Throws:
XMLStreamException
-
inPrologOrEpilog
protected final boolean inPrologOrEpilog()
-
copyStartElement
public abstract void copyStartElement(InputElementStack elemStack, AttributeCollector attrCollector) throws IOException, XMLStreamException
Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points to- Throws:
IOException
XMLStreamException
-
validateQNamePrefix
public abstract String validateQNamePrefix(QName name) throws XMLStreamException
Method called before writing a QName via Typed Access API. In namespace-repairing mode it should take appropriate actions to ensure that the given namespace URI is bound to a namespace and return whatever it maps to. In non-repairing work no additional work is to be done and methods- Returns:
- Prefix to use when writing out given QName as an element or attribute value
- Throws:
XMLStreamException
-
verifyWriteCData
protected final void verifyWriteCData() throws XMLStreamException
- Throws:
XMLStreamException
-
verifyWriteDTD
protected final void verifyWriteDTD() throws XMLStreamException
- Throws:
XMLStreamException
-
verifyRootElement
protected void verifyRootElement(String localName, String prefix) throws XMLStreamException
- Throws:
XMLStreamException
-
throwOutputError
protected static void throwOutputError(String msg) throws XMLStreamException
- Throws:
XMLStreamException
-
throwOutputError
protected static void throwOutputError(String format, Object arg) throws XMLStreamException
- Throws:
XMLStreamException
-
reportIllegalMethod
protected static void reportIllegalMethod(String msg) throws XMLStreamException
Method called when an illegal method (namespace-specific method on non-ns writer) is called by the application.- Throws:
XMLStreamException
-
reportNwfStructure
protected static void reportNwfStructure(String msg) throws XMLStreamException
This is the method called when an output method call violates structural well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE
is is enabled.- Throws:
XMLStreamException
-
reportNwfStructure
protected static void reportNwfStructure(String msg, Object arg) throws XMLStreamException
- Throws:
XMLStreamException
-
reportNwfContent
protected static void reportNwfContent(String msg) throws XMLStreamException
This is the method called when an output method call violates content well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT
is is enabled.- Throws:
XMLStreamException
-
reportNwfContent
protected static void reportNwfContent(String msg, Object arg) throws XMLStreamException
- Throws:
XMLStreamException
-
reportNwfAttr
protected static void reportNwfAttr(String msg) throws XMLStreamException
This is the method called when an output method call violates attribute well-formedness checks (trying to output dup attrs) andWstxOutputProperties.P_OUTPUT_VALIDATE_NAMES
is is enabled.- Throws:
XMLStreamException
-
reportNwfAttr
protected static void reportNwfAttr(String msg, Object arg) throws XMLStreamException
- Throws:
XMLStreamException
-
throwFromIOE
protected static void throwFromIOE(IOException ioe) throws XMLStreamException
- Throws:
XMLStreamException
-
reportIllegalArg
protected static void reportIllegalArg(String msg) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
reportInvalidContent
protected void reportInvalidContent(int evtType) throws XMLStreamException
- Throws:
XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(String msg, Location loc, int severity) throws XMLStreamException
- Throws:
XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(String msg, int severity) throws XMLStreamException
- Throws:
XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(String msg) throws XMLStreamException
- Throws:
XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(Location loc, String msg) throws XMLStreamException
- Throws:
XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(String format, Object arg) throws XMLStreamException
- Throws:
XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(String format, Object arg, Object arg2) throws XMLStreamException
- Throws:
XMLStreamException
-
doReportProblem
protected void doReportProblem(XMLReporter rep, String probType, String msg, Location loc) throws XMLStreamException
- Throws:
XMLStreamException
-
doReportProblem
protected void doReportProblem(XMLReporter rep, org.codehaus.stax2.validation.XMLValidationProblem prob) throws XMLStreamException
- Throws:
XMLStreamException
-
getTopElementDesc
protected abstract String getTopElementDesc()
Method needed for error message generation
-
getCopyBuffer
protected final char[] getCopyBuffer()
-
getCopyBuffer
protected final char[] getCopyBuffer(int minLen)
-
-