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 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 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 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
-
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 protectedBaseStreamWriter(XmlWriter xw, String enc, WriterConfig cfg)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intaddDefaultAttribute(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.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(XMLReporter rep, String probType, String msg, Location loc)protected voiddoReportProblem(XMLReporter rep, org.codehaus.stax2.validation.XMLValidationProblem prob)protected voiddoWriteStartDocument(String version, String encoding, String standAlone)intfindAttributeIndex(String nsURI, String localName)voidflush()intgetAttributeCount()StringgetAttributeLocalName(int index)StringgetAttributeNamespace(int index)StringgetAttributePrefix(int index)StringgetAttributeType(int index)StringgetAttributeValue(int index)StringgetAttributeValue(String nsURI, String localName)StringgetBaseUri()As of now, there is no way to specify the base URI.protected char[]getCopyBuffer()protected char[]getCopyBuffer(int minLen)abstract QNamegetCurrentElementName()StringgetEncoding()org.codehaus.stax2.XMLStreamLocation2getLocation()abstract NamespaceContextgetNamespaceContext()abstract StringgetNamespaceURI(String prefix)abstract StringgetPrefix(String uri)ObjectgetProperty(String name)protected abstract StringgetTopElementDesc()Method needed for error message generationLocationgetValidationLocation()StringgetXmlVersion()protected booleaninPrologOrEpilog()booleanisNotationDeclared(String name)booleanisPropertySupported(String name)booleanisUnparsedEntityDeclared(String name)protected booleanisValidating()Method that is used by output classes to determine whether we are in validating mode.protected static voidreportIllegalArg(String msg)protected static voidreportIllegalMethod(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(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(String msg, Object arg)protected static voidreportNwfContent(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(String msg, Object arg)protected static voidreportNwfStructure(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(String msg, Object arg)voidreportProblem(org.codehaus.stax2.validation.XMLValidationProblem prob)voidreportValidationProblem(String msg)voidreportValidationProblem(String msg, int severity)voidreportValidationProblem(String format, Object arg)voidreportValidationProblem(String format, Object arg, Object arg2)voidreportValidationProblem(String msg, Location loc, int severity)voidreportValidationProblem(Location loc, String msg)abstract voidsetDefaultNamespace(String uri)abstract voidsetNamespaceContext(NamespaceContext context)abstract voidsetPrefix(String prefix, String uri)booleansetProperty(String name, 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(IOException ioe)protected static voidthrowOutputError(String msg)protected static voidthrowOutputError(String format, Object arg)StringtoString()org.codehaus.stax2.validation.XMLValidatorvalidateAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema)abstract StringvalidateQNamePrefix(QName name)Method called before writing a QName via Typed Access API.protected voidverifyRootElement(String localName, String prefix)protected voidverifyWriteCData()protected voidverifyWriteDTD()WriterwrapAsRawWriter()Method that can be called to get a wrapper instance that can be used to essentially call thewriteRawmethod via regularWriterinterface.WriterwrapAsTextWriter()Method that can be called to get a wrapper instance that can be used to essentially call thewriteCharactersmethod via regularWriterinterface.abstract voidwriteAttribute(String localName, String value)abstract voidwriteAttribute(String nsURI, String localName, String value)abstract voidwriteAttribute(String prefix, String nsURI, String localName, String value)voidwriteCData(char[] cbuf, int start, int len)voidwriteCData(String data)voidwriteCharacters(char[] text, int start, int len)voidwriteCharacters(String text)voidwriteCharacters(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(String data)abstract voidwriteDefaultNamespace(String nsURI)voidwriteDTD(String dtd)voidwriteDTD(String rootName, String systemId, String publicId, String internalSubset)voidwriteDTD(org.codehaus.stax2.DTDInfo info)abstract voidwriteEmptyElement(String localName)abstract voidwriteEmptyElement(String nsURI, String localName)abstract voidwriteEmptyElement(String prefix, String localName, String nsURI)voidwriteEndDocument()abstract voidwriteEndElement()abstract voidwriteEndElement(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(String name)abstract voidwriteFullEndElement()abstract voidwriteNamespace(String prefix, String nsURI)voidwriteProcessingInstruction(String target)voidwriteProcessingInstruction(String target, String data)voidwriteRaw(char[] text, int start, int offset)voidwriteRaw(String text)voidwriteRaw(String text, int start, int offset)voidwriteSpace(char[] text, int offset, int length)voidwriteSpace(String text)voidwriteStartDocument()voidwriteStartDocument(String version)voidwriteStartDocument(String encoding, String version)voidwriteStartDocument(String version, String encoding, boolean standAlone)abstract voidwriteStartElement(String localName)abstract voidwriteStartElement(String nsURI, String localName)abstract voidwriteStartElement(String prefix, String localName, String nsURI)abstract voidwriteStartElement(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 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:
closein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
flush
public void flush() throws XMLStreamException- Specified by:
flushin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getNamespaceContext
public abstract NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContextin interfaceXMLStreamWriter
-
getPrefix
public abstract String getPrefix(String uri)
- Specified by:
getPrefixin interfaceXMLStreamWriter
-
getProperty
public Object getProperty(String name)
- Specified by:
getPropertyin interfaceXMLStreamWriter
-
setDefaultNamespace
public abstract void setDefaultNamespace(String uri) throws XMLStreamException
- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setNamespaceContext
public abstract void setNamespaceContext(NamespaceContext context) throws XMLStreamException
- Specified by:
setNamespaceContextin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setPrefix
public abstract void setPrefix(String prefix, String uri) throws XMLStreamException
- Specified by:
setPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(String localName, String value) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(String nsURI, String localName, String value) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(String prefix, String nsURI, String localName, String value) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCData
public void writeCData(String data) throws XMLStreamException
- Specified by:
writeCDatain interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(char[] text, int start, int len) throws XMLStreamException- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(String text) throws XMLStreamException
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeComment
public void writeComment(String data) throws XMLStreamException
- Specified by:
writeCommentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDefaultNamespace
public abstract void writeDefaultNamespace(String nsURI) throws XMLStreamException
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDTD
public void writeDTD(String dtd) throws XMLStreamException
- Specified by:
writeDTDin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(String localName) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(String nsURI, String localName) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public abstract void writeEmptyElement(String prefix, String localName, String nsURI) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndDocument
public void writeEndDocument() throws XMLStreamException- Specified by:
writeEndDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndElement
public abstract void writeEndElement() throws XMLStreamException- Specified by:
writeEndElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEntityRef
public void writeEntityRef(String name) throws XMLStreamException
- Specified by:
writeEntityRefin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeNamespace
public abstract void writeNamespace(String prefix, String nsURI) throws XMLStreamException
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String target) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String target, String data) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws XMLStreamException- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String version) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String encoding, String version) throws XMLStreamException
- Specified by:
writeStartDocumentin 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:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public abstract void writeStartElement(String nsURI, String localName) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public abstract void writeStartElement(String prefix, String localName, String nsURI) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
copyEventFromReader
public void copyEventFromReader(org.codehaus.stax2.XMLStreamReader2 sr, boolean preserveEventData) throws 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:
XMLStreamException
-
closeCompletely
public void closeCompletely() throws XMLStreamException- Specified by:
closeCompletelyin interfaceorg.codehaus.stax2.XMLStreamWriter2- Throws:
XMLStreamException
-
isPropertySupported
public boolean isPropertySupported(String name)
- Specified by:
isPropertySupportedin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
isPropertySupportedin classorg.codehaus.stax2.ri.Stax2WriterImpl
-
setProperty
public boolean setProperty(String name, 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 XMLStreamException- Specified by:
validateAgainstin interfaceorg.codehaus.stax2.validation.Validatable- Overrides:
validateAgainstin 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:
stopValidatingAgainstin interfaceorg.codehaus.stax2.validation.Validatable- Overrides:
stopValidatingAgainstin 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:
stopValidatingAgainstin interfaceorg.codehaus.stax2.validation.Validatable- Overrides:
stopValidatingAgainstin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
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
-
getLocation
public org.codehaus.stax2.XMLStreamLocation2 getLocation()
- Specified by:
getLocationin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
getLocationin classorg.codehaus.stax2.ri.Stax2WriterImpl
-
getEncoding
public 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 XMLStreamException- Specified by:
writeCDatain interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeCDatain 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:
writeDTDin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeDTDin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
writeFullEndElement
public abstract void writeFullEndElement() throws XMLStreamException- Specified by:
writeFullEndElementin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeFullEndElementin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String version, String encoding, boolean standAlone) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
writeStartDocumentin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
writeRaw
public void writeRaw(String text) throws XMLStreamException
- Specified by:
writeRawin interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeRawin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
writeRaw
public void writeRaw(String text, int start, int offset) throws XMLStreamException
- Specified by:
writeRawin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
writeRawin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
writeRaw
public void writeRaw(char[] text, int start, int offset) throws XMLStreamException- Specified by:
writeRawin interfaceorg.codehaus.stax2.XMLStreamWriter2- Specified by:
writeRawin classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
writeSpace
public void writeSpace(String text) throws XMLStreamException
- Specified by:
writeSpacein interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeSpacein classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
writeSpace
public void writeSpace(char[] text, int offset, int length) throws XMLStreamException- Specified by:
writeSpacein interfaceorg.codehaus.stax2.XMLStreamWriter2- Overrides:
writeSpacein classorg.codehaus.stax2.ri.Stax2WriterImpl- Throws:
XMLStreamException
-
getXmlVersion
public String getXmlVersion()
- Specified by:
getXmlVersionin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getCurrentElementName
public abstract QName getCurrentElementName()
- Specified by:
getCurrentElementNamein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getNamespaceURI
public abstract String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURIin 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:
getBaseUriin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getValidationLocation
public Location getValidationLocation()
- Specified by:
getValidationLocationin interfaceorg.codehaus.stax2.validation.ValidationContext
-
reportProblem
public void reportProblem(org.codehaus.stax2.validation.XMLValidationProblem prob) throws XMLStreamException- Specified by:
reportProblemin 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:
addDefaultAttributein interfaceorg.codehaus.stax2.validation.ValidationContext
-
isNotationDeclared
public boolean isNotationDeclared(String name)
- Specified by:
isNotationDeclaredin interfaceorg.codehaus.stax2.validation.ValidationContext
-
isUnparsedEntityDeclared
public boolean isUnparsedEntityDeclared(String name)
- Specified by:
isUnparsedEntityDeclaredin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCountin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeLocalName
public String getAttributeLocalName(int index)
- Specified by:
getAttributeLocalNamein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeNamespace
public String getAttributeNamespace(int index)
- Specified by:
getAttributeNamespacein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributePrefix
public String getAttributePrefix(int index)
- Specified by:
getAttributePrefixin interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeValue
public String getAttributeValue(int index)
- Specified by:
getAttributeValuein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeValue
public String getAttributeValue(String nsURI, String localName)
- Specified by:
getAttributeValuein interfaceorg.codehaus.stax2.validation.ValidationContext
-
getAttributeType
public String getAttributeType(int index)
- Specified by:
getAttributeTypein interfaceorg.codehaus.stax2.validation.ValidationContext
-
findAttributeIndex
public int findAttributeIndex(String nsURI, String localName)
- Specified by:
findAttributeIndexin 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 thewriteRawmethod via regularWriterinterface.
-
wrapAsTextWriter
public final 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(StartElement elem) throws XMLStreamException
Convenience method needed byXMLEventWriterimplementation, 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 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:
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:
IOExceptionXMLStreamException
-
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_STRUCTUREis 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_CONTENTis 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_NAMESis 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)
-
-