Package com.ctc.wstx.sw
Class BaseStreamWriter
- java.lang.Object
-
- org.codehaus.stax2.ri.Stax2WriterImpl
-
- com.ctc.wstx.sw.BaseStreamWriter
-
- All Implemented Interfaces:
OutputConfigFlags,javax.xml.stream.XMLStreamConstants,javax.xml.stream.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 forXMLStreamWriterimplementations 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 intATTR_MIN_ARRAYCOPYprotected static charCHAR_SPACEprotected static intDEFAULT_COPYBUFFER_LENprotected booleanmAnyOutputFlag that is set to true first time something has been output.protected booleanmCfgAutomaticEmptyElemsprotected booleanmCfgCDataAsTextprotected booleanmCfgCopyDefaultAttrsprotected booleanmCheckAttrsprotected booleanmCheckStructureprotected WriterConfigmConfigprotected char[]mCopyBufferIntermediate 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 java.lang.StringmDtdRootElemValue passed as the expected root element, when using the multiple argumentwriteDTD(java.lang.String)method.protected booleanmEmptyElementFlag 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 java.lang.StringmEncodingEncoding 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 intMIN_ARRAYCOPYThis 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 booleanmReturnNullForDefaultNamespaceprotected booleanmStartElementOpenFlag that is set during time that a start element is "open", ie.protected intmStateprotected org.codehaus.stax2.validation.XMLValidatormValidatorOptional validator to use for validating output against one or more schemas, and/or for safe pretty-printing (indentation).protected intmVldContentState value used with validation, to track types of content that is allowed at this point in output stream.protected org.codehaus.stax2.validation.ValidationProblemHandlermVldProbHandlerCustom validation problem handler, if any.protected XmlWritermWriterActual physical writer to output serialized XML content toprotected booleanmXml11Since 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 intSTATE_EPILOGprotected static intSTATE_PROLOGprotected static intSTATE_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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseStreamWriter(XmlWriter xw, java.lang.String enc, WriterConfig cfg)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private void_finishDocument(boolean forceRealClose)intaddDefaultAttribute(java.lang.String localName, java.lang.String uri, java.lang.String prefix, java.lang.String value)Adding default attribute values does not usually make sense on output side, so the implementation is a NOP for now.voidclose()voidcloseCompletely()protected abstract voidcloseStartElement(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.voidcopyEventFromReader(org.codehaus.stax2.XMLStreamReader2 sr, boolean preserveEventData)Method that essentially copies event that the specified reader has just read.abstract voidcopyStartElement(InputElementStack elemStack, AttributeCollector attrCollector)Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points toprotected voiddoReportProblem(javax.xml.stream.XMLReporter rep, java.lang.String probType, java.lang.String msg, javax.xml.stream.Location loc)protected voiddoReportProblem(javax.xml.stream.XMLReporter rep, org.codehaus.stax2.validation.XMLValidationProblem prob)protected voiddoWriteStartDocument(java.lang.String version, java.lang.String encoding, java.lang.String standAlone)intfindAttributeIndex(java.lang.String nsURI, java.lang.String localName)voidflush()intgetAttributeCount()java.lang.StringgetAttributeLocalName(int index)java.lang.StringgetAttributeNamespace(int index)java.lang.StringgetAttributePrefix(int index)java.lang.StringgetAttributeType(int index)java.lang.StringgetAttributeValue(int index)java.lang.StringgetAttributeValue(java.lang.String nsURI, java.lang.String localName)java.lang.StringgetBaseUri()As of now, there is no way to specify the base URI.protected char[]getCopyBuffer()protected char[]getCopyBuffer(int minLen)abstract javax.xml.namespace.QNamegetCurrentElementName()java.lang.StringgetEncoding()org.codehaus.stax2.XMLStreamLocation2getLocation()abstract javax.xml.namespace.NamespaceContextgetNamespaceContext()abstract java.lang.StringgetNamespaceURI(java.lang.String prefix)abstract java.lang.StringgetPrefix(java.lang.String uri)java.lang.ObjectgetProperty(java.lang.String name)protected abstract java.lang.StringgetTopElementDesc()Method needed for error message generationjavax.xml.stream.LocationgetValidationLocation()java.lang.StringgetXmlVersion()protected booleaninPrologOrEpilog()booleanisNotationDeclared(java.lang.String name)booleanisPropertySupported(java.lang.String name)booleanisUnparsedEntityDeclared(java.lang.String name)protected booleanisValidating()Method that is used by output classes to determine whether we are in validating mode.protected static voidreportIllegalArg(java.lang.String msg)protected static voidreportIllegalMethod(java.lang.String msg)Method called when an illegal method (namespace-specific method on non-ns writer) is called by the application.protected voidreportInvalidContent(int evtType)protected static voidreportNwfAttr(java.lang.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_NAMESis is enabled.protected static voidreportNwfAttr(java.lang.String msg, java.lang.Object arg)protected static voidreportNwfContent(java.lang.String msg)This is the method called when an output method call violates content well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_CONTENTis is enabled.protected static voidreportNwfContent(java.lang.String msg, java.lang.Object arg)protected static voidreportNwfStructure(java.lang.String msg)This is the method called when an output method call violates structural well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTUREis is enabled.protected static voidreportNwfStructure(java.lang.String msg, java.lang.Object arg)voidreportProblem(org.codehaus.stax2.validation.XMLValidationProblem prob)voidreportValidationProblem(java.lang.String msg)voidreportValidationProblem(java.lang.String msg, int severity)voidreportValidationProblem(java.lang.String format, java.lang.Object arg)voidreportValidationProblem(java.lang.String format, java.lang.Object arg, java.lang.Object arg2)voidreportValidationProblem(java.lang.String msg, javax.xml.stream.Location loc, int severity)voidreportValidationProblem(javax.xml.stream.Location loc, java.lang.String msg)private voidresetValidationFlags()abstract voidsetDefaultNamespace(java.lang.String uri)abstract voidsetNamespaceContext(javax.xml.namespace.NamespaceContext context)abstract voidsetPrefix(java.lang.String prefix, java.lang.String uri)booleansetProperty(java.lang.String name, java.lang.Object value)org.codehaus.stax2.validation.ValidationProblemHandlersetValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler h)org.codehaus.stax2.validation.XMLValidatorstopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema)org.codehaus.stax2.validation.XMLValidatorstopValidatingAgainst(org.codehaus.stax2.validation.XMLValidator validator)protected static voidthrowFromIOE(java.io.IOException ioe)protected static voidthrowOutputError(java.lang.String msg)protected static voidthrowOutputError(java.lang.String format, java.lang.Object arg)java.lang.StringtoString()org.codehaus.stax2.validation.XMLValidatorvalidateAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema)abstract java.lang.StringvalidateQNamePrefix(javax.xml.namespace.QName name)Method called before writing a QName via Typed Access API.protected voidverifyRootElement(java.lang.String localName, java.lang.String prefix)protected voidverifyWriteCData()protected voidverifyWriteDTD()java.io.WriterwrapAsRawWriter()Method that can be called to get a wrapper instance that can be used to essentially call thewriteRawmethod via regularWriterinterface.java.io.WriterwrapAsTextWriter()Method that can be called to get a wrapper instance that can be used to essentially call thewriteCharactersmethod via regularWriterinterface.abstract voidwriteAttribute(java.lang.String localName, java.lang.String value)abstract voidwriteAttribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value)abstract voidwriteAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.lang.String value)voidwriteCData(char[] cbuf, int start, int len)voidwriteCData(java.lang.String data)voidwriteCharacters(char[] text, int start, int len)voidwriteCharacters(java.lang.String text)voidwriteCharacters(javax.xml.stream.events.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.voidwriteComment(java.lang.String data)abstract voidwriteDefaultNamespace(java.lang.String nsURI)voidwriteDTD(java.lang.String dtd)voidwriteDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset)voidwriteDTD(org.codehaus.stax2.DTDInfo info)abstract voidwriteEmptyElement(java.lang.String localName)abstract voidwriteEmptyElement(java.lang.String nsURI, java.lang.String localName)abstract voidwriteEmptyElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)voidwriteEndDocument()abstract voidwriteEndElement()abstract voidwriteEndElement(javax.xml.namespace.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.voidwriteEntityRef(java.lang.String name)abstract voidwriteFullEndElement()abstract voidwriteNamespace(java.lang.String prefix, java.lang.String nsURI)voidwriteProcessingInstruction(java.lang.String target)voidwriteProcessingInstruction(java.lang.String target, java.lang.String data)voidwriteRaw(char[] text, int start, int offset)voidwriteRaw(java.lang.String text)voidwriteRaw(java.lang.String text, int start, int offset)voidwriteSpace(char[] text, int offset, int length)voidwriteSpace(java.lang.String text)voidwriteStartDocument()voidwriteStartDocument(java.lang.String version)voidwriteStartDocument(java.lang.String encoding, java.lang.String version)voidwriteStartDocument(java.lang.String version, java.lang.String encoding, boolean standAlone)abstract voidwriteStartElement(java.lang.String localName)abstract voidwriteStartElement(java.lang.String nsURI, java.lang.String localName)abstract voidwriteStartElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)abstract voidwriteStartElement(javax.xml.stream.events.StartElement elem)Convenience method needed byXMLEventWriterimplementation, 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 java.lang.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 java.lang.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, java.lang.String enc, WriterConfig cfg)
-
-
Method Detail
-
close
public void close() throws javax.xml.stream.XMLStreamException- Specified by:
closein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
flush
public void flush() throws javax.xml.stream.XMLStreamException- Specified by:
flushin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
getNamespaceContext
public abstract javax.xml.namespace.NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContextin interfacejavax.xml.stream.XMLStreamWriter
-
getPrefix
public abstract java.lang.String getPrefix(java.lang.String uri)
- Specified by:
getPrefixin interfacejavax.xml.stream.XMLStreamWriter
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getPropertyin interfacejavax.xml.stream.XMLStreamWriter
-
setDefaultNamespace
public abstract void setDefaultNamespace(java.lang.String uri) throws javax.xml.stream.XMLStreamException- Specified by:
setDefaultNamespacein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
setNamespaceContext
public abstract void setNamespaceContext(javax.xml.namespace.NamespaceContext context) throws javax.xml.stream.XMLStreamException- Specified by:
setNamespaceContextin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
setPrefix
public abstract void setPrefix(java.lang.String prefix, java.lang.String uri) throws javax.xml.stream.XMLStreamException- Specified by:
setPrefixin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeAttribute
public abstract void writeAttribute(java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException- Specified by:
writeAttributein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeAttribute
public abstract void writeAttribute(java.lang.String nsURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException- Specified by:
writeAttributein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeAttribute
public abstract void writeAttribute(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.lang.String value) throws javax.xml.stream.XMLStreamException- Specified by:
writeAttributein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeCData
public void writeCData(java.lang.String data) throws javax.xml.stream.XMLStreamException- Specified by:
writeCDatain interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeCharacters
public void writeCharacters(char[] text, int start, int len) throws javax.xml.stream.XMLStreamException- Specified by:
writeCharactersin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeCharacters
public void writeCharacters(java.lang.String text) throws javax.xml.stream.XMLStreamException- Specified by:
writeCharactersin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeComment
public void writeComment(java.lang.String data) throws javax.xml.stream.XMLStreamException- Specified by:
writeCommentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDefaultNamespace
public abstract void writeDefaultNamespace(java.lang.String nsURI) throws javax.xml.stream.XMLStreamException- Specified by:
writeDefaultNamespacein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeDTD
public void writeDTD(java.lang.String dtd) throws javax.xml.stream.XMLStreamException- Specified by:
writeDTDin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException- Specified by:
writeEmptyElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(java.lang.String nsURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException- Specified by:
writeEmptyElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI) throws javax.xml.stream.XMLStreamException- Specified by:
writeEmptyElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEndDocument
public void writeEndDocument() throws javax.xml.stream.XMLStreamException- Specified by:
writeEndDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEndElement
public abstract void writeEndElement() throws javax.xml.stream.XMLStreamException- Specified by:
writeEndElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeEntityRef
public void writeEntityRef(java.lang.String name) throws javax.xml.stream.XMLStreamException- Specified by:
writeEntityRefin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeNamespace
public abstract void writeNamespace(java.lang.String prefix, java.lang.String nsURI) throws javax.xml.stream.XMLStreamException- Specified by:
writeNamespacein interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(java.lang.String target) throws javax.xml.stream.XMLStreamException- Specified by:
writeProcessingInstructionin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(java.lang.String target, java.lang.String data) throws javax.xml.stream.XMLStreamException- Specified by:
writeProcessingInstructionin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws javax.xml.stream.XMLStreamException- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String version) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String encoding, java.lang.String version) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartDocumentin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
doWriteStartDocument
protected void doWriteStartDocument(java.lang.String version, java.lang.String encoding, java.lang.String standAlone) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
writeStartElement
public abstract void writeStartElement(java.lang.String localName) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartElement
public abstract void writeStartElement(java.lang.String nsURI, java.lang.String localName) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
writeStartElement
public abstract void writeStartElement(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartElementin interfacejavax.xml.stream.XMLStreamWriter- Throws:
javax.xml.stream.XMLStreamException
-
copyEventFromReader
public void copyEventFromReader(org.codehaus.stax2.XMLStreamReader2 sr, boolean preserveEventData) throws javax.xml.stream.XMLStreamExceptionMethod that essentially copies event that the specified reader has just read.- Specified by:
copyEventFromReaderin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
copyEventFromReaderin 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:
javax.xml.stream.XMLStreamException
-
closeCompletely
public void closeCompletely() throws javax.xml.stream.XMLStreamException- Specified by:
closeCompletelyin interfaceorg.codehaus.stax2.XMLStreamWriter2- Throws:
javax.xml.stream.XMLStreamException
-
isPropertySupported
public boolean isPropertySupported(java.lang.String name)
- Specified by:
isPropertySupportedin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
isPropertySupportedin classorg.codehaus.stax2.ri.Stax2WriterImpl
-
setProperty
public boolean setProperty(java.lang.String name, java.lang.Object value)- Specified by:
setPropertyin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
setPropertyin 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 javax.xml.stream.XMLStreamException- Specified by:
validateAgainstin interfaceorg.codehaus.stax2.validation.Validatable- Overrides:
validateAgainstin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema) throws javax.xml.stream.XMLStreamException- Specified by:
stopValidatingAgainstin interfaceorg.codehaus.stax2.validation.Validatable- Overrides:
stopValidatingAgainstin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
stopValidatingAgainst
public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidator validator) throws javax.xml.stream.XMLStreamException- Specified by:
stopValidatingAgainstin interfaceorg.codehaus.stax2.validation.Validatable- Overrides:
stopValidatingAgainstin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
setValidationProblemHandler
public org.codehaus.stax2.validation.ValidationProblemHandler setValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler h)
- Specified by:
setValidationProblemHandlerin interfaceorg.codehaus.stax2.validation.Validatable- Overrides:
setValidationProblemHandlerin classorg.codehaus.stax2.ri.Stax2WriterImpl
-
resetValidationFlags
private void resetValidationFlags()
-
getLocation
public org.codehaus.stax2.XMLStreamLocation2 getLocation()
- Specified by:
getLocationin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
getLocationin classorg.codehaus.stax2.ri.Stax2WriterImpl
-
getEncoding
public java.lang.String getEncoding()
- Specified by:
getEncodingin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
getEncodingin classorg.codehaus.stax2.ri.Stax2WriterImpl
-
writeCData
public void writeCData(char[] cbuf, int start, int len) throws javax.xml.stream.XMLStreamException- Specified by:
writeCDatain interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeCDatain classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeDTD
public void writeDTD(org.codehaus.stax2.DTDInfo info) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
writeDTD
public void writeDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset) throws javax.xml.stream.XMLStreamException- Specified by:
writeDTDin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeDTDin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeFullEndElement
public abstract void writeFullEndElement() throws javax.xml.stream.XMLStreamException- Specified by:
writeFullEndElementin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeFullEndElementin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeStartDocument
public void writeStartDocument(java.lang.String version, java.lang.String encoding, boolean standAlone) throws javax.xml.stream.XMLStreamException- Specified by:
writeStartDocumentin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
writeStartDocumentin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeRaw
public void writeRaw(java.lang.String text) throws javax.xml.stream.XMLStreamException- Specified by:
writeRawin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeRawin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeRaw
public void writeRaw(java.lang.String text, int start, int offset) throws javax.xml.stream.XMLStreamException- Specified by:
writeRawin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
writeRawin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeRaw
public void writeRaw(char[] text, int start, int offset) throws javax.xml.stream.XMLStreamException- Specified by:
writeRawin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
writeRawin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeSpace
public void writeSpace(java.lang.String text) throws javax.xml.stream.XMLStreamException- Specified by:
writeSpacein interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeSpacein classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
writeSpace
public void writeSpace(char[] text, int offset, int length) throws javax.xml.stream.XMLStreamException- Specified by:
writeSpacein interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeSpacein classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
javax.xml.stream.XMLStreamException
-
getXmlVersion
public java.lang.String getXmlVersion()
- Specified by:
getXmlVersionin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getCurrentElementName
public abstract javax.xml.namespace.QName getCurrentElementName()
- Specified by:
getCurrentElementNamein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getNamespaceURI
public abstract java.lang.String getNamespaceURI(java.lang.String prefix)
- Specified by:
getNamespaceURIin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getBaseUri
public java.lang.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:
getBaseUriin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getValidationLocation
public javax.xml.stream.Location getValidationLocation()
- Specified by:
getValidationLocationin interfaceorg.codehaus.stax2.validation.ValidationContext
-
reportProblem
public void reportProblem(org.codehaus.stax2.validation.XMLValidationProblem prob) throws javax.xml.stream.XMLStreamException- Specified by:
reportProblemin interfaceorg.codehaus.stax2.validation.ValidationContext- Throws:
javax.xml.stream.XMLStreamException
-
addDefaultAttribute
public int addDefaultAttribute(java.lang.String localName, java.lang.String uri, java.lang.String prefix, java.lang.String value)Adding default attribute values does not usually make sense on output side, so the implementation is a NOP for now.- Specified by:
addDefaultAttributein interfaceorg.codehaus.stax2.validation.ValidationContext
-
isNotationDeclared
public boolean isNotationDeclared(java.lang.String name)
- Specified by:
isNotationDeclaredin interfaceorg.codehaus.stax2.validation.ValidationContext
-
isUnparsedEntityDeclared
public boolean isUnparsedEntityDeclared(java.lang.String name)
- Specified by:
isUnparsedEntityDeclaredin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCountin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeLocalName
public java.lang.String getAttributeLocalName(int index)
- Specified by:
getAttributeLocalNamein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeNamespace
public java.lang.String getAttributeNamespace(int index)
- Specified by:
getAttributeNamespacein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributePrefix
public java.lang.String getAttributePrefix(int index)
- Specified by:
getAttributePrefixin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeValue
public java.lang.String getAttributeValue(int index)
- Specified by:
getAttributeValuein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String nsURI, java.lang.String localName)- Specified by:
getAttributeValuein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeType
public java.lang.String getAttributeType(int index)
- Specified by:
getAttributeTypein interfaceorg.codehaus.stax2.validation.ValidationContext
-
findAttributeIndex
public int findAttributeIndex(java.lang.String nsURI, java.lang.String localName)- Specified by:
findAttributeIndexin interfaceorg.codehaus.stax2.validation.ValidationContext
-
wrapAsRawWriter
public final java.io.Writer wrapAsRawWriter()
Method that can be called to get a wrapper instance that can be used to essentially call thewriteRawmethod via regularWriterinterface.
-
wrapAsTextWriter
public final java.io.Writer wrapAsTextWriter()
Method that can be called to get a wrapper instance that can be used to essentially call thewriteCharactersmethod via regularWriterinterface.
-
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(javax.xml.stream.events.StartElement elem) throws javax.xml.stream.XMLStreamExceptionConvenience method needed byXMLEventWriterimplementation, to use when writing a start element, and possibly its attributes and namespace declarations.- Throws:
javax.xml.stream.XMLStreamException
-
writeEndElement
public abstract void writeEndElement(javax.xml.namespace.QName name) throws javax.xml.stream.XMLStreamExceptionMethod called byXMLEventWriter(instead of the version that takes no argument), so that we can verify it does match the start element if necessary.- Throws:
javax.xml.stream.XMLStreamException
-
writeCharacters
public void writeCharacters(javax.xml.stream.events.Characters ch) throws javax.xml.stream.XMLStreamExceptionMethod 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:
javax.xml.stream.XMLStreamException
-
closeStartElement
protected abstract void closeStartElement(boolean emptyElem) throws javax.xml.stream.XMLStreamExceptionMethod 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:
javax.xml.stream.XMLStreamException
-
inPrologOrEpilog
protected final boolean inPrologOrEpilog()
-
_finishDocument
private final void _finishDocument(boolean forceRealClose) throws javax.xml.stream.XMLStreamException- Parameters:
forceRealClose- If true, will force calling of close() on the underlying physical result (stream, writer). If false, will let XmlWriter decide whether to call close(); will be done if auto-closing enabled, but not otherwise.- Throws:
javax.xml.stream.XMLStreamException
-
copyStartElement
public abstract void copyStartElement(InputElementStack elemStack, AttributeCollector attrCollector) throws java.io.IOException, javax.xml.stream.XMLStreamException
Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points to- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
validateQNamePrefix
public abstract java.lang.String validateQNamePrefix(javax.xml.namespace.QName name) throws javax.xml.stream.XMLStreamExceptionMethod 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:
javax.xml.stream.XMLStreamException
-
verifyWriteCData
protected final void verifyWriteCData() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
verifyWriteDTD
protected final void verifyWriteDTD() throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
verifyRootElement
protected void verifyRootElement(java.lang.String localName, java.lang.String prefix) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
throwOutputError
protected static void throwOutputError(java.lang.String msg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
throwOutputError
protected static void throwOutputError(java.lang.String format, java.lang.Object arg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportIllegalMethod
protected static void reportIllegalMethod(java.lang.String msg) throws javax.xml.stream.XMLStreamExceptionMethod called when an illegal method (namespace-specific method on non-ns writer) is called by the application.- Throws:
javax.xml.stream.XMLStreamException
-
reportNwfStructure
protected static void reportNwfStructure(java.lang.String msg) throws javax.xml.stream.XMLStreamExceptionThis is the method called when an output method call violates structural well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTUREis is enabled.- Throws:
javax.xml.stream.XMLStreamException
-
reportNwfStructure
protected static void reportNwfStructure(java.lang.String msg, java.lang.Object arg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportNwfContent
protected static void reportNwfContent(java.lang.String msg) throws javax.xml.stream.XMLStreamExceptionThis is the method called when an output method call violates content well-formedness checks andWstxOutputProperties.P_OUTPUT_VALIDATE_CONTENTis is enabled.- Throws:
javax.xml.stream.XMLStreamException
-
reportNwfContent
protected static void reportNwfContent(java.lang.String msg, java.lang.Object arg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportNwfAttr
protected static void reportNwfAttr(java.lang.String msg) throws javax.xml.stream.XMLStreamExceptionThis is the method called when an output method call violates attribute well-formedness checks (trying to output dup attrs) andWstxOutputProperties.P_OUTPUT_VALIDATE_NAMESis is enabled.- Throws:
javax.xml.stream.XMLStreamException
-
reportNwfAttr
protected static void reportNwfAttr(java.lang.String msg, java.lang.Object arg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
throwFromIOE
protected static void throwFromIOE(java.io.IOException ioe) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportIllegalArg
protected static void reportIllegalArg(java.lang.String msg) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
reportInvalidContent
protected void reportInvalidContent(int evtType) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(java.lang.String msg, javax.xml.stream.Location loc, int severity) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(java.lang.String msg, int severity) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(java.lang.String msg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(javax.xml.stream.Location loc, java.lang.String msg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(java.lang.String format, java.lang.Object arg) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
reportValidationProblem
public void reportValidationProblem(java.lang.String format, java.lang.Object arg, java.lang.Object arg2) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
doReportProblem
protected void doReportProblem(javax.xml.stream.XMLReporter rep, java.lang.String probType, java.lang.String msg, javax.xml.stream.Location loc) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
doReportProblem
protected void doReportProblem(javax.xml.stream.XMLReporter rep, org.codehaus.stax2.validation.XMLValidationProblem prob) throws javax.xml.stream.XMLStreamException- Throws:
javax.xml.stream.XMLStreamException
-
getTopElementDesc
protected abstract java.lang.String getTopElementDesc()
Method needed for error message generation
-
getCopyBuffer
protected final char[] getCopyBuffer()
-
getCopyBuffer
protected final char[] getCopyBuffer(int minLen)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-