Package com.fasterxml.aalto.out
Class RepairingStreamWriter
java.lang.Object
org.codehaus.stax2.ri.Stax2WriterImpl
com.fasterxml.aalto.out.StreamWriterBase
com.fasterxml.aalto.out.RepairingStreamWriter
- All Implemented Interfaces:
NamespaceContext,XMLStreamConstants,XMLStreamWriter,org.codehaus.stax2.typed.TypedXMLStreamWriter,org.codehaus.stax2.validation.Validatable,org.codehaus.stax2.validation.ValidationContext,org.codehaus.stax2.XMLStreamWriter2
Concrete implementation of
StreamWriterBase, which
implements the "namespace repairing" mode of operation.
This means that the writer ensures correctness and validity
of namespace bindings, as based on namespace URIs caller
passes, by adding necessary namespace declarations and using
prefixes as required to obtain expected results.-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.aalto.out.StreamWriterBase
StreamWriterBase.State -
Field Summary
FieldsModifier and TypeFieldDescription(package private) int[]Sequence number used for generating dynamic namespace prefixes.(package private) final String(package private) StringMap that contains URI-to-prefix entries that point out suggested prefixes for URIs.Fields inherited from class com.fasterxml.aalto.out.StreamWriterBase
_cfgCDataAsText, _cfgCheckAttrs, _cfgCheckContent, _cfgCheckStructure, _config, _currElem, _dtdRootElemName, _outputElemPool, _poolSize, _rootNsContext, _state, _stateAnyOutput, _stateEmptyElement, _stateStartElementOpen, _symbols, _validator, _valueEncoderFactory, _vldContent, _vldProblemHandler, _xmlWriter, MAX_POOL_SIZEFields 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
ConstructorsConstructorDescriptionRepairingStreamWriter(WriterConfig cfg, XmlWriter writer, WNameTable symbols) -
Method Summary
Modifier and TypeMethodDescriptionprotected WName_generateAttrName(String suggPrefix, String localName, String uri) protected final StringMethod called if given URI is not yet bound, and no suggested prefix is given (or one given can't be used).protected String_serializeQName(QName name) void_setPrefix(String prefix, String uri) private final boolean_writeStartAndVerify(String prefix, String localName, String nsURI, boolean isEmpty) void_writeStartOrEmpty(String prefix, String localName, String nsURI, boolean isEmpty) voidWith repairing writer, this is only taken as a suggestion as to how the caller would prefer prefixes to be mapped.voidwriteAttribute(String nsURI, String localName, String value) voidwriteAttribute(String prefix, String nsURI, String localName, String value) voidwriteDefaultNamespace(String nsURI) voidwriteEmptyElement(String nsURI, String localName) voidwriteEmptyElement(String prefix, String localName, String nsURI) voidwriteNamespace(String prefix, String nsURI) voidwriteStartElement(String nsURI, String localName) voidwriteStartElement(String prefix, String localName, String nsURI) voidwriteTypedAttribute(String prefix, String nsURI, String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) Need to leave implementation of this method abstract, because repairing and non-repairing modes differ in how names are handled.Methods inherited from class com.fasterxml.aalto.out.StreamWriterBase
_closeStartElement, _reportInvalidContent, _reportNwfAttr, _reportNwfAttr, _reportNwfContent, _reportNwfContent, _reportNwfName, _reportNwfStructure, _reportNwfStructure, _reportValidationProblem, _verifyRootElement, _verifyStartElement, _verifyWriteAttr, _verifyWriteCData, _verifyWriteDTD, _writeAttribute, _writeAttribute, _writeDefaultNamespace, _writeNamespace, _writeStartDocument, _writeStartTag, _writeStartTag, addDefaultAttribute, close, closeCompletely, findAttributeIndex, flush, getAttributeCount, getAttributeLocalName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getBaseUri, getCurrentElementName, getEncoding, getLocation, getNamespaceContext, getNamespaceURI, getPrefix, getPrefixes, getProperty, getValidationLocation, getXmlVersion, inPrologOrEpilog, isNotationDeclared, isPropertySupported, isUnparsedEntityDeclared, reportIllegalArg, reportIllegalMethod, reportProblem, setNamespaceContext, setPrefix, setProperty, setValidationProblemHandler, stopValidatingAgainst, stopValidatingAgainst, throwFromIOE, throwOutputError, throwOutputError, toString, validateAgainst, valueEncoderFactory, writeAttribute, writeBinary, writeBinary, writeBinaryAttribute, writeBinaryAttribute, writeBoolean, writeBooleanAttribute, writeCData, writeCData, writeCharacters, writeCharacters, writeComment, writeDecimal, writeDecimalAttribute, writeDouble, writeDoubleArray, writeDoubleArrayAttribute, writeDoubleAttribute, writeDTD, writeDTD, writeDTD, writeEmptyElement, writeEndDocument, writeEndElement, writeEntityRef, writeFloat, writeFloatArray, writeFloatArrayAttribute, writeFloatAttribute, writeFullEndElement, writeInt, writeIntArray, writeIntArrayAttribute, writeIntAttribute, writeInteger, writeIntegerAttribute, writeLong, writeLongArray, writeLongArrayAttribute, writeLongAttribute, writeProcessingInstruction, writeProcessingInstruction, writeQName, writeQNameAttribute, writeRaw, writeRaw, writeRaw, writeSpace, writeSpace, writeStartDocument, writeStartDocument, writeStartDocument, writeStartDocument, writeStartElementMethods inherited from class org.codehaus.stax2.ri.Stax2WriterImpl
copyEventFromReader, copyStartElement
-
Field Details
-
_cfgAutomaticNsPrefix
-
_autoNsSeq
int[] _autoNsSeqSequence number used for generating dynamic namespace prefixes. Array used as a wrapper to allow for easy sharing of the sequence number. -
_suggestedDefNs
String _suggestedDefNs -
_suggestedPrefixes
Map that contains URI-to-prefix entries that point out suggested prefixes for URIs. These are populated by calls toStreamWriterBase.setPrefix(java.lang.String, java.lang.String), and they are only used as hints for binding; if there are conflicts, repairing writer can just use some other prefix.
-
-
Constructor Details
-
RepairingStreamWriter
-
-
Method Details
-
setDefaultNamespace
With repairing writer, this is only taken as a suggestion as to how the caller would prefer prefixes to be mapped.- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Specified by:
setDefaultNamespacein classStreamWriterBase- Throws:
XMLStreamException
-
_setPrefix
- Specified by:
_setPrefixin classStreamWriterBase
-
writeAttribute
- Specified by:
writeAttributein interfaceXMLStreamWriter- Specified by:
writeAttributein classStreamWriterBase- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String prefix, String nsURI, String localName, String value) throws XMLStreamException - Specified by:
writeAttributein interfaceXMLStreamWriter- Specified by:
writeAttributein classStreamWriterBase- Throws:
XMLStreamException
-
writeDefaultNamespace
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Specified by:
writeDefaultNamespacein classStreamWriterBase- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Specified by:
writeEmptyElementin classStreamWriterBase- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String prefix, String localName, String nsURI) throws XMLStreamException - Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Specified by:
writeEmptyElementin classStreamWriterBase- Throws:
XMLStreamException
-
writeNamespace
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Specified by:
writeNamespacein classStreamWriterBase- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Specified by:
writeStartElementin classStreamWriterBase- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String prefix, String localName, String nsURI) throws XMLStreamException - Specified by:
writeStartElementin interfaceXMLStreamWriter- Specified by:
writeStartElementin classStreamWriterBase- Throws:
XMLStreamException
-
writeTypedAttribute
public void writeTypedAttribute(String prefix, String nsURI, String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws XMLStreamException Description copied from class:StreamWriterBaseNeed to leave implementation of this method abstract, because repairing and non-repairing modes differ in how names are handled.- Specified by:
writeTypedAttributein classStreamWriterBase- Throws:
XMLStreamException
-
_serializeQName
- Specified by:
_serializeQNamein classStreamWriterBase- Throws:
XMLStreamException
-
_generateAttrName
protected WName _generateAttrName(String suggPrefix, String localName, String uri) throws XMLStreamException - Parameters:
uri- Non-empty namespace URI that will be used for the attribute- Throws:
XMLStreamException
-
_writeStartOrEmpty
public void _writeStartOrEmpty(String prefix, String localName, String nsURI, boolean isEmpty) throws XMLStreamException - Throws:
XMLStreamException
-
_writeStartAndVerify
private final boolean _writeStartAndVerify(String prefix, String localName, String nsURI, boolean isEmpty) throws XMLStreamException - Returns:
- True, if prefix indicates default namespace (is null or empty); false otherwise
- Throws:
XMLStreamException
-
_generateElemPrefix
Method called if given URI is not yet bound, and no suggested prefix is given (or one given can't be used). If so, methods is to create a not-yet-bound-prefix for the namespace.- Throws:
XMLStreamException
-