|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ctc.wstx.sw.BaseStreamWriter
Base class for XMLStreamWriter implementations 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 | |
protected static char |
CHAR_SPACE
|
protected static java.lang.String |
DEFAULT_ENCODING
Default encoding we assume, if nothing is passed explicitly. |
protected static char |
DEFAULT_QUOTE_CHAR
|
protected boolean |
mAnyOutput
Flag that is set to true first time something has been output. |
protected AttributeCollector |
mAttrCollector
|
protected java.io.Writer |
mAttrValueWriter
Lazy-constructed writer that will properly escape characters of attribute values that need escaping ('<', '&', '"'). |
protected boolean |
mCfgAutomaticEmptyElems
|
protected boolean |
mCfgCDataAsText
|
protected boolean |
mCfgCopyDefaultAttrs
|
protected boolean |
mCheckAttr
|
protected boolean |
mCheckContent
|
protected boolean |
mCheckNames
|
protected boolean |
mCheckStructure
|
protected WriterConfig |
mConfig
|
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). |
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 to writeStartDocument(), or null if
neither. |
protected boolean |
mFixContent
|
protected InputElementStack |
mInputElemStack
|
protected XMLStreamReader2 |
mLastReader
Reader that was last used for copy-through operation; used in conjunction with the other copy-through state variables. |
protected StreamReaderImpl |
mLastReaderImpl
|
protected boolean |
mNsAware
|
protected boolean |
mStartElementOpen
Flag that is set during time that a start element is "open", ie. |
protected int |
mState
|
protected java.io.Writer |
mTextWriter
Lazy-constructed writer that will properly escape characters of text content that need escaping ('<', '&' etc). |
protected java.io.Writer |
mWriter
Actual physical writer to output serialized XML content to |
protected static int |
STATE_EPILOG
|
protected static int |
STATE_PROLOG
|
protected static int |
STATE_TREE
|
| 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 |
| Fields inherited from interface com.ctc.wstx.cfg.OutputConfigFlags |
CFG_AUTOMATIC_EMPTY_ELEMS, CFG_AUTOMATIC_NS, CFG_COPY_DEFAULT_ATTRS, CFG_ENABLE_NS, CFG_FIX_CONTENT, CFG_OUTPUT_CDATA_AS_TEXT, CFG_VALIDATE_ATTR, CFG_VALIDATE_CONTENT, CFG_VALIDATE_NAMES, CFG_VALIDATE_STRUCTURE |
| Constructor Summary | |
protected |
BaseStreamWriter(java.io.Writer w,
java.lang.String enc,
WriterConfig cfg)
|
| Method Summary | |
void |
close()
|
protected abstract 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. |
protected java.io.Writer |
constructAttributeValueWriter()
|
protected java.io.Writer |
constructTextWriter()
|
void |
copyEventFromReader(XMLStreamReader2 sr,
boolean preserveEventData)
Method that essentially copies event that the specified reader has just read. |
abstract void |
copyStartElement(InputElementStack elemStack,
AttributeCollector attrCollector)
Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points to |
protected void |
doWriteStartDocument(java.lang.String version,
java.lang.String encoding,
java.lang.String standAlone)
|
void |
flush()
|
void |
flushStream()
|
java.lang.Object |
getFeature(java.lang.String name)
|
abstract javax.xml.namespace.NamespaceContext |
getNamespaceContext()
|
abstract java.lang.String |
getPrefix(java.lang.String uri)
|
java.lang.Object |
getProperty(java.lang.String name)
|
java.io.Writer |
getWriter()
Method needed by WstxEventWriter, when it
needs/wants to
do direct output, without calling methods in this class (not often). |
boolean |
inPrologOrEpilog()
|
void |
safeFlushStream()
|
abstract void |
setDefaultNamespace(java.lang.String uri)
|
void |
setFeature(java.lang.String name,
java.lang.Object value)
|
abstract void |
setNamespaceContext(javax.xml.namespace.NamespaceContext context)
|
abstract void |
setPrefix(java.lang.String prefix,
java.lang.String uri)
|
protected static void |
throwFromIOE(java.io.IOException ioe)
|
protected static void |
throwIllegalArg(java.lang.String msg)
|
protected static void |
throwIllegalArg(java.lang.String format,
java.lang.Object arg)
|
protected static void |
throwOutputError(java.lang.String msg)
|
protected static void |
throwOutputError(java.lang.String format,
java.lang.Object arg)
|
protected int |
verifyCDataContent(char[] c,
int start,
int end)
|
protected int |
verifyCDataContent(java.lang.String content)
|
protected int |
verifyCommentContent(java.lang.String content)
|
static void |
verifyNameValidity(java.lang.String name,
boolean nsAware)
Method called to verify that the name is a legal XML name. |
protected void |
verifyWriteDTD()
|
abstract void |
writeAttribute(java.lang.String localName,
java.lang.String value)
|
abstract void |
writeAttribute(java.lang.String nsURI,
java.lang.String localName,
java.lang.String value)
|
abstract void |
writeAttribute(java.lang.String prefix,
java.lang.String nsURI,
java.lang.String localName,
java.lang.String value)
|
void |
writeCData(char[] c,
int start,
int len)
|
void |
writeCData(java.lang.String data)
|
void |
writeCharacters(char[] text,
int start,
int len)
|
void |
writeCharacters(javax.xml.stream.events.Characters ch)
Method called by WstxEventWriter (instead of
more generic
text output methods), so that we can verify (if necessary) that
this character output type is legal in this context. |
void |
writeCharacters(java.lang.String text)
|
void |
writeComment(java.lang.String data)
|
abstract void |
writeDefaultNamespace(java.lang.String nsURI)
|
void |
writeDTD(DTDInfo info)
|
void |
writeDTD(java.lang.String dtd)
|
void |
writeDTD(java.lang.String rootName,
java.lang.String systemId,
java.lang.String publicId,
java.lang.String internalSubset)
|
abstract void |
writeEmptyElement(java.lang.String localName)
|
abstract void |
writeEmptyElement(java.lang.String nsURI,
java.lang.String localName)
|
abstract void |
writeEmptyElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String nsURI)
|
void |
writeEndDocument()
|
abstract void |
writeEndElement()
|
abstract void |
writeEndElement(javax.xml.namespace.QName name)
Method called by WstxEventWriter (instead of the version
that takes no argument), so that we can verify it does match the
start element, if necessary |
void |
writeEntityRef(java.lang.String name)
|
abstract void |
writeFullEndElement()
Method similar to writeEndElement(), but that will always
write the full end element, instead of empty element. |
abstract void |
writeNamespace(java.lang.String prefix,
java.lang.String nsURI)
|
void |
writeProcessingInstruction(java.lang.String target)
|
void |
writeProcessingInstruction(java.lang.String target,
java.lang.String data)
|
void |
writeRaw(char[] text,
int offset,
int length)
Method that writes specified content as is, without encoding or deciphering it in any way. |
void |
writeRaw(java.lang.String text)
Method that writes specified content as is, without encoding or deciphering it in any way. |
protected void |
writeSegmentedCData(char[] c,
int start,
int len,
int index)
|
protected void |
writeSegmentedCData(java.lang.String content,
int index)
|
protected void |
writeSegmentedComment(java.lang.String content,
int index)
|
void |
writeStartDocument()
|
void |
writeStartDocument(java.lang.String version)
|
void |
writeStartDocument(java.lang.String encoding,
java.lang.String version)
|
void |
writeStartDocument(java.lang.String version,
java.lang.String encoding,
boolean standAlone)
|
abstract void |
writeStartElement(javax.xml.stream.events.StartElement elem)
Convenience method needed by WstxEventWriter, to use when
writing a start element, and possibly its attributes and namespace
declarations. |
abstract void |
writeStartElement(java.lang.String localName)
|
abstract void |
writeStartElement(java.lang.String nsURI,
java.lang.String localName)
|
abstract void |
writeStartElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String nsURI)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static final int STATE_PROLOG
protected static final int STATE_TREE
protected static final int STATE_EPILOG
protected static final char CHAR_SPACE
protected static final char DEFAULT_QUOTE_CHAR
protected static final java.lang.String DEFAULT_ENCODING
protected final java.io.Writer mWriter
protected java.io.Writer mTextWriter
mWriter for actual outputting.
protected java.io.Writer mAttrValueWriter
mWriter for actual outputting.
protected final WriterConfig mConfig
protected final boolean mNsAware
protected final boolean mCfgAutomaticEmptyElems
protected final boolean mCfgCDataAsText
protected final boolean mCfgCopyDefaultAttrs
protected final boolean mCheckStructure
protected final boolean mCheckContent
protected final boolean mCheckAttr
protected final boolean mCheckNames
protected final boolean mFixContent
protected java.lang.String mEncoding
writeStartDocument(), 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).
protected int mState
protected boolean mAnyOutput
protected boolean mStartElementOpen
protected boolean mEmptyElement
protected XMLStreamReader2 mLastReader
protected StreamReaderImpl mLastReaderImpl
protected AttributeCollector mAttrCollector
protected InputElementStack mInputElemStack
| Constructor Detail |
protected BaseStreamWriter(java.io.Writer w,
java.lang.String enc,
WriterConfig cfg)
| Method Detail |
protected java.io.Writer constructAttributeValueWriter()
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
protected java.io.Writer constructTextWriter()
throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public void close()
throws javax.xml.stream.XMLStreamException
close in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void flush()
throws javax.xml.stream.XMLStreamException
flush in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamExceptionpublic abstract javax.xml.namespace.NamespaceContext getNamespaceContext()
getNamespaceContext in interface javax.xml.stream.XMLStreamWriterpublic abstract java.lang.String getPrefix(java.lang.String uri)
getPrefix in interface javax.xml.stream.XMLStreamWriterpublic java.lang.Object getProperty(java.lang.String name)
getProperty in interface javax.xml.stream.XMLStreamWriter
public abstract void setDefaultNamespace(java.lang.String uri)
throws javax.xml.stream.XMLStreamException
setDefaultNamespace in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamExceptionpublic abstract void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
setNamespaceContext in interface javax.xml.stream.XMLStreamWriter
public abstract void setPrefix(java.lang.String prefix,
java.lang.String uri)
throws javax.xml.stream.XMLStreamException
setPrefix in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeAttribute(java.lang.String localName,
java.lang.String value)
throws javax.xml.stream.XMLStreamException
writeAttribute in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeAttribute(java.lang.String nsURI,
java.lang.String localName,
java.lang.String value)
throws javax.xml.stream.XMLStreamException
writeAttribute in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
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
writeAttribute in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeCData(java.lang.String data)
throws javax.xml.stream.XMLStreamException
writeCData in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeCharacters(char[] text,
int start,
int len)
throws javax.xml.stream.XMLStreamException
writeCharacters in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeCharacters(java.lang.String text)
throws javax.xml.stream.XMLStreamException
writeCharacters in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeComment(java.lang.String data)
throws javax.xml.stream.XMLStreamException
writeComment in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeDefaultNamespace(java.lang.String nsURI)
throws javax.xml.stream.XMLStreamException
writeDefaultNamespace in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeDTD(java.lang.String dtd)
throws javax.xml.stream.XMLStreamException
writeDTD in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeEmptyElement(java.lang.String localName)
throws javax.xml.stream.XMLStreamException
writeEmptyElement in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeEmptyElement(java.lang.String nsURI,
java.lang.String localName)
throws javax.xml.stream.XMLStreamException
writeEmptyElement in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeEmptyElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String nsURI)
throws javax.xml.stream.XMLStreamException
writeEmptyElement in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeEndDocument()
throws javax.xml.stream.XMLStreamException
writeEndDocument in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeEndElement()
throws javax.xml.stream.XMLStreamException
writeEndElement in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeEntityRef(java.lang.String name)
throws javax.xml.stream.XMLStreamException
writeEntityRef in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeNamespace(java.lang.String prefix,
java.lang.String nsURI)
throws javax.xml.stream.XMLStreamException
writeNamespace in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeProcessingInstruction(java.lang.String target)
throws javax.xml.stream.XMLStreamException
writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeProcessingInstruction(java.lang.String target,
java.lang.String data)
throws javax.xml.stream.XMLStreamException
writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeStartDocument()
throws javax.xml.stream.XMLStreamException
writeStartDocument in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String version)
throws javax.xml.stream.XMLStreamException
writeStartDocument in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String encoding,
java.lang.String version)
throws javax.xml.stream.XMLStreamException
writeStartDocument in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
protected void doWriteStartDocument(java.lang.String version,
java.lang.String encoding,
java.lang.String standAlone)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public abstract void writeStartElement(java.lang.String localName)
throws javax.xml.stream.XMLStreamException
writeStartElement in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeStartElement(java.lang.String nsURI,
java.lang.String localName)
throws javax.xml.stream.XMLStreamException
writeStartElement in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamException
public abstract void writeStartElement(java.lang.String prefix,
java.lang.String localName,
java.lang.String nsURI)
throws javax.xml.stream.XMLStreamException
writeStartElement in interface javax.xml.stream.XMLStreamWriterjavax.xml.stream.XMLStreamExceptionpublic java.lang.Object getFeature(java.lang.String name)
getFeature in interface XMLStreamWriter2name - Name of the feature of which value to get
public void setFeature(java.lang.String name,
java.lang.Object value)
setFeature in interface XMLStreamWriter2name - Name of the feature to setvalue - Value to set feature to.
public void writeCData(char[] c,
int start,
int len)
throws javax.xml.stream.XMLStreamException
writeCData in interface XMLStreamWriter2javax.xml.stream.XMLStreamException
public void writeDTD(DTDInfo info)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public void writeDTD(java.lang.String rootName,
java.lang.String systemId,
java.lang.String publicId,
java.lang.String internalSubset)
throws javax.xml.stream.XMLStreamException
writeDTD in interface XMLStreamWriter2javax.xml.stream.XMLStreamException
public abstract void writeFullEndElement()
throws javax.xml.stream.XMLStreamException
XMLStreamWriter2XMLStreamWriter.writeEndElement(), but that will always
write the full end element, instead of empty element. This only
matters for cases where the element itself has no content, and
if writer is allowed to write empty elements when it encounters
such start/end element write pairs.
writeFullEndElement in interface XMLStreamWriter2javax.xml.stream.XMLStreamException
public void writeStartDocument(java.lang.String version,
java.lang.String encoding,
boolean standAlone)
throws javax.xml.stream.XMLStreamException
writeStartDocument in interface XMLStreamWriter2javax.xml.stream.XMLStreamException
public void writeRaw(java.lang.String text)
throws javax.xml.stream.XMLStreamException
XMLStreamWriter2Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.
writeRaw in interface XMLStreamWriter2javax.xml.stream.XMLStreamException
public void writeRaw(char[] text,
int offset,
int length)
throws javax.xml.stream.XMLStreamException
XMLStreamWriter2Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.
writeRaw in interface XMLStreamWriter2javax.xml.stream.XMLStreamException
public void copyEventFromReader(XMLStreamReader2 sr,
boolean preserveEventData)
throws javax.xml.stream.XMLStreamException
copyEventFromReader in interface XMLStreamWriter2sr - 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.
javax.xml.stream.XMLStreamExceptionpublic java.io.Writer getWriter()
WstxEventWriter, when it
needs/wants to
do direct output, without calling methods in this class (not often).
public abstract void writeStartElement(javax.xml.stream.events.StartElement elem)
throws javax.xml.stream.XMLStreamException
WstxEventWriter, to use when
writing a start element, and possibly its attributes and namespace
declarations.
javax.xml.stream.XMLStreamException
public abstract void writeEndElement(javax.xml.namespace.QName name)
throws javax.xml.stream.XMLStreamException
WstxEventWriter (instead of the version
that takes no argument), so that we can verify it does match the
start element, if necessary
javax.xml.stream.XMLStreamException
public void writeCharacters(javax.xml.stream.events.Characters ch)
throws javax.xml.stream.XMLStreamException
WstxEventWriter (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).
javax.xml.stream.XMLStreamException
protected abstract void closeStartElement(boolean emptyElem)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionpublic boolean inPrologOrEpilog()
public abstract void copyStartElement(InputElementStack elemStack,
AttributeCollector attrCollector)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
public void flushStream()
throws java.io.IOException
java.io.IOException
public void safeFlushStream()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public static void verifyNameValidity(java.lang.String name,
boolean nsAware)
protected void verifyWriteDTD()
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamExceptionprotected int verifyCDataContent(java.lang.String content)
protected int verifyCDataContent(char[] c,
int start,
int end)
protected int verifyCommentContent(java.lang.String content)
protected void writeSegmentedCData(java.lang.String content,
int index)
throws java.io.IOException
java.io.IOException
protected void writeSegmentedCData(char[] c,
int start,
int len,
int index)
throws java.io.IOException
java.io.IOException
protected void writeSegmentedComment(java.lang.String content,
int index)
throws java.io.IOException
java.io.IOException
protected static void throwOutputError(java.lang.String msg)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void throwOutputError(java.lang.String format,
java.lang.Object arg)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void throwFromIOE(java.io.IOException ioe)
throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected static void throwIllegalArg(java.lang.String msg)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
protected static void throwIllegalArg(java.lang.String format,
java.lang.Object arg)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||