Package com.ctc.wstx.sw
Class NonNsStreamWriter
java.lang.Object
org.codehaus.stax2.ri.Stax2WriterImpl
com.ctc.wstx.sw.BaseStreamWriter
com.ctc.wstx.sw.TypedStreamWriter
com.ctc.wstx.sw.NonNsStreamWriter
- 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
Implementation of
XMLStreamWriter
used when namespace support
is not enabled. This means that only local names are used for elements
and attributes; and if rudimentary namespace declarations need to be
output, they are output using attribute writing methods.-
Field Summary
FieldsModifier and TypeFieldDescriptionContainer for attribute names for current element; used only if uniqueness of attribute names is to be enforced.(package private) final StringVector
Stack of currently open start elements; only local names are included.Fields inherited from class com.ctc.wstx.sw.TypedStreamWriter
mValueEncoderFactory
Fields inherited from class com.ctc.wstx.sw.BaseStreamWriter
ATTR_MIN_ARRAYCOPY, CHAR_SPACE, DEFAULT_COPYBUFFER_LEN, mAnyOutput, mCfgAutomaticEmptyElems, mCfgCDataAsText, mCfgCopyDefaultAttrs, mCheckAttrs, mCheckStructure, mConfig, mCopyBuffer, mDtdRootElem, mEmptyElement, mEncoding, MIN_ARRAYCOPY, mReturnNullForDefaultNamespace, mStartElementOpen, mState, mValidator, mVldContent, mVldProbHandler, mWriter, mXml11, STATE_EPILOG, STATE_PROLOG, 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
copyStartElement
(InputElementStack elemStack, AttributeCollector attrCollector) Element copier method implementation suitable to be used with non-namespace-aware writers.private void
doWriteEndTag
(String expName, boolean allowEmpty) Note: Caller has to do actual removal of the element from element stack, before calling this method.private void
doWriteStartElement
(String localName) getNamespaceURI
(String prefix) protected String
Method needed for error message generationvoid
void
setNamespaceContext
(NamespaceContext context) void
validateQNamePrefix
(QName name) Method called before writing a QName via Typed Access API.void
writeAttribute
(String localName, String value) void
writeAttribute
(String nsURI, String localName, String value) void
writeAttribute
(String prefix, String nsURI, String localName, String value) void
writeDefaultNamespace
(String nsURI) void
writeEmptyElement
(String localName) void
writeEmptyElement
(String nsURI, String localName) void
writeEmptyElement
(String prefix, String localName, String nsURI) void
void
writeEndElement
(QName name) Method called byXMLEventWriter
implementation (instead of the version that takes no argument), so that we can verify it does match the start element, if necessaryvoid
Similar towriteEndElement()
, but never allows implicit creation of empty elements.void
writeNamespace
(String prefix, String nsURI) void
writeStartElement
(String localName) void
writeStartElement
(String nsURI, String localName) void
writeStartElement
(String prefix, String localName, String nsURI) void
Convenience method needed byXMLEventWriter
implementation, to use when writing a start element, and possibly its attributes and namespace declarations.protected void
writeTypedAttribute
(String prefix, String nsURI, String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) Method that will write attribute with value that is known not to require additional escaping.Methods inherited from class com.ctc.wstx.sw.TypedStreamWriter
valueEncoderFactory, 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, writeTypedElement
Methods inherited from class com.ctc.wstx.sw.BaseStreamWriter
addDefaultAttribute, close, closeCompletely, copyEventFromReader, doReportProblem, doReportProblem, doWriteStartDocument, findAttributeIndex, flush, getAttributeCount, getAttributeLocalName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getBaseUri, getCopyBuffer, getCopyBuffer, getEncoding, getLocation, getProperty, getValidationLocation, getXmlVersion, inPrologOrEpilog, isNotationDeclared, isPropertySupported, isUnparsedEntityDeclared, isValidating, reportIllegalArg, reportIllegalMethod, reportInvalidContent, reportNwfAttr, reportNwfAttr, reportNwfContent, reportNwfContent, reportNwfStructure, reportNwfStructure, reportProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, reportValidationProblem, setProperty, setValidationProblemHandler, stopValidatingAgainst, stopValidatingAgainst, throwFromIOE, throwOutputError, throwOutputError, toString, validateAgainst, verifyRootElement, verifyWriteCData, verifyWriteDTD, wrapAsRawWriter, wrapAsTextWriter, writeCData, writeCData, writeCharacters, writeCharacters, writeCharacters, writeComment, writeDTD, writeDTD, writeDTD, writeEndDocument, writeEntityRef, writeProcessingInstruction, writeProcessingInstruction, writeRaw, writeRaw, writeRaw, writeSpace, writeSpace, writeStartDocument, writeStartDocument, writeStartDocument, writeStartDocument
Methods inherited from class org.codehaus.stax2.ri.Stax2WriterImpl
copyStartElement
-
Field Details
-
mElements
Stack of currently open start elements; only local names are included. -
mAttrNames
Container for attribute names for current element; used only if uniqueness of attribute names is to be enforced.TreeSet is used mostly because clearing it up is faster than clearing up HashSet, and the only access is done by adding entries and see if an value was already set.
-
-
Constructor Details
-
NonNsStreamWriter
-
-
Method Details
-
getNamespaceContext
- Specified by:
getNamespaceContext
in interfaceXMLStreamWriter
- Specified by:
getNamespaceContext
in classBaseStreamWriter
-
getPrefix
- Specified by:
getPrefix
in interfaceXMLStreamWriter
- Specified by:
getPrefix
in classBaseStreamWriter
-
setDefaultNamespace
- Specified by:
setDefaultNamespace
in interfaceXMLStreamWriter
- Specified by:
setDefaultNamespace
in classBaseStreamWriter
- Throws:
XMLStreamException
-
setNamespaceContext
- Specified by:
setNamespaceContext
in interfaceXMLStreamWriter
- Specified by:
setNamespaceContext
in classBaseStreamWriter
-
setPrefix
- Specified by:
setPrefix
in interfaceXMLStreamWriter
- Specified by:
setPrefix
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
- Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Specified by:
writeAttribute
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
- Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Specified by:
writeAttribute
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String prefix, String nsURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttribute
in interfaceXMLStreamWriter
- Specified by:
writeAttribute
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeDefaultNamespace
- Specified by:
writeDefaultNamespace
in interfaceXMLStreamWriter
- Specified by:
writeDefaultNamespace
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Specified by:
writeEmptyElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Specified by:
writeEmptyElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String prefix, String localName, String nsURI) throws XMLStreamException - Specified by:
writeEmptyElement
in interfaceXMLStreamWriter
- Specified by:
writeEmptyElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeEndElement
- Specified by:
writeEndElement
in interfaceXMLStreamWriter
- Specified by:
writeEndElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeNamespace
- Specified by:
writeNamespace
in interfaceXMLStreamWriter
- Specified by:
writeNamespace
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Specified by:
writeStartElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Specified by:
writeStartElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String prefix, String localName, String nsURI) throws XMLStreamException - Specified by:
writeStartElement
in interfaceXMLStreamWriter
- Specified by:
writeStartElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeFullEndElement
Similar towriteEndElement()
, but never allows implicit creation of empty elements.- Specified by:
writeFullEndElement
in interfaceorg.codehaus.stax2.XMLStreamWriter2
- Specified by:
writeFullEndElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
getCurrentElementName
- Specified by:
getCurrentElementName
in interfaceorg.codehaus.stax2.validation.ValidationContext
- Specified by:
getCurrentElementName
in classBaseStreamWriter
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceorg.codehaus.stax2.validation.ValidationContext
- Specified by:
getNamespaceURI
in classBaseStreamWriter
-
writeStartElement
Description copied from class:BaseStreamWriter
Convenience method needed byXMLEventWriter
implementation, to use when writing a start element, and possibly its attributes and namespace declarations.- Specified by:
writeStartElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeEndElement
Method called byXMLEventWriter
implementation (instead of the version that takes no argument), so that we can verify it does match the start element, if necessary- Specified by:
writeEndElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
writeTypedAttribute
protected void writeTypedAttribute(String prefix, String nsURI, String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws XMLStreamException Description copied from class:TypedStreamWriter
Method that will write attribute with value that is known not to require additional escaping.- Specified by:
writeTypedAttribute
in classTypedStreamWriter
- Throws:
XMLStreamException
-
closeStartElement
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.- Specified by:
closeStartElement
in classBaseStreamWriter
- Throws:
XMLStreamException
-
copyStartElement
public void copyStartElement(InputElementStack elemStack, AttributeCollector attrCollector) throws IOException, XMLStreamException Element copier method implementation suitable to be used with non-namespace-aware writers. The only special thing here is that the copier can convert namespace declarations to equivalent attribute writes.- Specified by:
copyStartElement
in classBaseStreamWriter
- Throws:
IOException
XMLStreamException
-
getTopElementDesc
Description copied from class:BaseStreamWriter
Method needed for error message generation- Specified by:
getTopElementDesc
in classBaseStreamWriter
-
validateQNamePrefix
Description copied from class:BaseStreamWriter
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- Specified by:
validateQNamePrefix
in classBaseStreamWriter
- Returns:
- Prefix to use when writing out given QName as an element or attribute value
-
doWriteStartElement
- Throws:
XMLStreamException
-
doWriteEndTag
Note: Caller has to do actual removal of the element from element stack, before calling this method.
- Parameters:
expName
- Name that the closing element should have; null if whatever is in stack should be usedallowEmpty
- If true, is allowed to create the empty element if the closing element was truly empty; if false, has to write the full empty element no matter what- Throws:
XMLStreamException
-