com.ctc.wstx.sw
Class NonNsStreamWriter

java.lang.Object
  extended by org.codehaus.stax2.ri.Stax2WriterImpl
      extended by com.ctc.wstx.sw.BaseStreamWriter
          extended by com.ctc.wstx.sw.TypedStreamWriter
              extended by com.ctc.wstx.sw.NonNsStreamWriter
All Implemented Interfaces:
OutputConfigFlags, XMLStreamConstants, XMLStreamWriter, TypedXMLStreamWriter, Validatable, ValidationContext, XMLStreamWriter2

public class NonNsStreamWriter
extends TypedStreamWriter

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
 
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_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
NonNsStreamWriter(XmlWriter xw, String enc, WriterConfig cfg)
           
 
Method Summary
protected  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.
 QName getCurrentElementName()
          Method that can be used to access name information of the innermost (top) element in the element stack.
 NamespaceContext getNamespaceContext()
           
 String getNamespaceURI(String prefix)
          Method that can be called by the validator to resolve a namespace prefix of the currently active top-level element.
 String getPrefix(String uri)
           
protected  String getTopElementDesc()
          Method needed for error message generation
 void setDefaultNamespace(String uri)
           
 void setNamespaceContext(NamespaceContext context)
           
 void setPrefix(String prefix, String uri)
           
 String 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 writeEndElement()
           
 void writeEndElement(QName name)
          Method called by XMLEventWriter implementation (instead of the version that takes no argument), so that we can verify it does match the start element, if necessary
 void writeFullEndElement()
          Similar to writeEndElement(), but never allows implicit creation of empty elements.
 void writeNamespace(String prefix, String nsURI)
           
 void writeStartElement(StartElement elem)
          Convenience method needed by XMLEventWriter implementation, to use when writing a start element, and possibly its attributes and namespace declarations.
 void writeStartElement(String localName)
           
 void writeStartElement(String nsURI, String localName)
           
 void writeStartElement(String prefix, String localName, String nsURI)
           
protected  void writeTypedAttribute(String prefix, String nsURI, String localName, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NonNsStreamWriter

public NonNsStreamWriter(XmlWriter xw,
                         String enc,
                         WriterConfig cfg)
Method Detail

getNamespaceContext

public NamespaceContext getNamespaceContext()
Specified by:
getNamespaceContext in interface XMLStreamWriter
Specified by:
getNamespaceContext in class BaseStreamWriter

getPrefix

public String getPrefix(String uri)
Specified by:
getPrefix in interface XMLStreamWriter
Specified by:
getPrefix in class BaseStreamWriter

setDefaultNamespace

public void setDefaultNamespace(String uri)
                         throws XMLStreamException
Specified by:
setDefaultNamespace in interface XMLStreamWriter
Specified by:
setDefaultNamespace in class BaseStreamWriter
Throws:
XMLStreamException

setNamespaceContext

public void setNamespaceContext(NamespaceContext context)
Specified by:
setNamespaceContext in interface XMLStreamWriter
Specified by:
setNamespaceContext in class BaseStreamWriter

setPrefix

public void setPrefix(String prefix,
                      String uri)
               throws XMLStreamException
Specified by:
setPrefix in interface XMLStreamWriter
Specified by:
setPrefix in class BaseStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Specified by:
writeAttribute in class BaseStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String nsURI,
                           String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Specified by:
writeAttribute in class BaseStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String prefix,
                           String nsURI,
                           String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Specified by:
writeAttribute in class BaseStreamWriter
Throws:
XMLStreamException

writeDefaultNamespace

public void writeDefaultNamespace(String nsURI)
                           throws XMLStreamException
Specified by:
writeDefaultNamespace in interface XMLStreamWriter
Specified by:
writeDefaultNamespace in class BaseStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String localName)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Specified by:
writeEmptyElement in class BaseStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String nsURI,
                              String localName)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Specified by:
writeEmptyElement in class BaseStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String prefix,
                              String localName,
                              String nsURI)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Specified by:
writeEmptyElement in class BaseStreamWriter
Throws:
XMLStreamException

writeEndElement

public void writeEndElement()
                     throws XMLStreamException
Specified by:
writeEndElement in interface XMLStreamWriter
Specified by:
writeEndElement in class BaseStreamWriter
Throws:
XMLStreamException

writeNamespace

public void writeNamespace(String prefix,
                           String nsURI)
                    throws XMLStreamException
Specified by:
writeNamespace in interface XMLStreamWriter
Specified by:
writeNamespace in class BaseStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String localName)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Specified by:
writeStartElement in class BaseStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String nsURI,
                              String localName)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Specified by:
writeStartElement in class BaseStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String prefix,
                              String localName,
                              String nsURI)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Specified by:
writeStartElement in class BaseStreamWriter
Throws:
XMLStreamException

writeFullEndElement

public void writeFullEndElement()
                         throws XMLStreamException
Similar to writeEndElement(), but never allows implicit creation of empty elements.

Specified by:
writeFullEndElement in interface XMLStreamWriter2
Specified by:
writeFullEndElement in class BaseStreamWriter
Throws:
XMLStreamException

getCurrentElementName

public QName getCurrentElementName()
Description copied from interface: ValidationContext
Method that can be used to access name information of the innermost (top) element in the element stack.

Specified by:
getCurrentElementName in interface ValidationContext
Specified by:
getCurrentElementName in class BaseStreamWriter
Returns:
Name of the element at the top of the current element stack, if any. During validation calls it refers to the element being processed (start or end tag), or its parent (when processing text nodes), or null (in document prolog and epilog).

getNamespaceURI

public String getNamespaceURI(String prefix)
Description copied from interface: ValidationContext
Method that can be called by the validator to resolve a namespace prefix of the currently active top-level element. This may be necessary for things like DTD validators (which may need to heuristically guess proper namespace URI of attributes, esp. ones with default values).

Specified by:
getNamespaceURI in interface ValidationContext
Specified by:
getNamespaceURI in class BaseStreamWriter

writeStartElement

public void writeStartElement(StartElement elem)
                       throws XMLStreamException
Description copied from class: BaseStreamWriter
Convenience method needed by XMLEventWriter implementation, to use when writing a start element, and possibly its attributes and namespace declarations.

Specified by:
writeStartElement in class BaseStreamWriter
Throws:
XMLStreamException

writeEndElement

public void writeEndElement(QName name)
                     throws XMLStreamException
Method called by XMLEventWriter 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 class BaseStreamWriter
Throws:
XMLStreamException

writeTypedAttribute

protected void writeTypedAttribute(String prefix,
                                   String nsURI,
                                   String localName,
                                   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 class TypedStreamWriter
Throws:
XMLStreamException

closeStartElement

protected void closeStartElement(boolean emptyElem)
                          throws XMLStreamException
Method called to close an open start element, when another main-level element (not namespace declaration or attribute) is being output; except for end element which is handled differently.

Specified by:
closeStartElement in class BaseStreamWriter
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 class BaseStreamWriter
Throws:
IOException
XMLStreamException

getTopElementDesc

protected String getTopElementDesc()
Description copied from class: BaseStreamWriter
Method needed for error message generation

Specified by:
getTopElementDesc in class BaseStreamWriter

validateQNamePrefix

public String validateQNamePrefix(QName name)
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 class BaseStreamWriter
Returns:
Prefix to use when writing out given QName as an element or attribute value