Class SMRootFragment
java.lang.Object
org.codehaus.staxmate.out.SMOutputtable
org.codehaus.staxmate.out.SMOutputContainer
org.codehaus.staxmate.out.SMRootFragment
- Direct Known Subclasses:
SMOutputDocument
Concrete non-buffered fragment (== container) class used as the root
level output container. Root-level does not necessarily have to mean
XML root level; it may also be a child context of a stream writer
in which StaxMate is only used to output specific sub-trees.
This class is also used as the base for the outputter that models
a complete document.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanSimple state flag; children can only be added when root container is still active.Fields inherited from class SMOutputContainer
_context, _firstChild, _lastChild, _parentFields inherited from class SMOutputtable
_next -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanMethod called to figure out if we can just output a newly added child, without any buffering.protected void_childReleased(SMOutputtable child) Method called by a child, when it is released and neither is or contains any buffered entities.protected void_forceOutput(SMOutputContext ctxt) Method similar toSMOutputtable._output(SMOutputContext, boolean), except that this method will always succeed in doing the output.protected boolean_output(SMOutputContext ctxt, boolean canClose) Method called to request that the entity output itself; either as much as it can without closing, or as much as it can if it is to get closed.voidMethod that HAS to be called when all additions have been done via StaxMate API.voidvoidgetPath(StringBuilder sb) Method that can be called to get an XPath like description of the relative location of this output node, starting from root.private final voidMethods inherited from class SMOutputContainer
_closeAllButLastChild, _closeAndOutputChildren, _forceChildOutput, _linkNewChild, _throwClosed, _throwRelinking, _verifyNamespaceArg, addAndReleaseBuffered, addBuffered, addCData, addCData, addCharacters, addCharacters, addComment, addElement, addElement, addElementWithCharacters, addEntityRef, addProcessingInstruction, addValue, addValue, addValue, addValue, addValue, addValue, createBufferedElement, createBufferedFragment, getContext, getNamespace, getNamespace, getParent, getPath, setIndentationMethods inherited from class SMOutputtable
_linkNext, getNext
-
Field Details
-
_active
protected boolean _activeSimple state flag; children can only be added when root container is still active.
-
-
Constructor Details
-
SMRootFragment
-
-
Method Details
-
_output
Description copied from class:SMOutputtableMethod called to request that the entity output itself; either as much as it can without closing, or as much as it can if it is to get closed. In both cases output can fail or be only a partial one: buffered nodes will not be output at all, and nodes with buffered children can only be partially output.- Specified by:
_outputin classSMOutputContainer- Parameters:
ctxt- Output context to use for outputting this node (and its contents)canClose- If true, indicates that the node can (and should) be fully closed if possible. This (passing true) is usually done when a new sibling is added after a node (element/fragment); if so, current one should be recursively closed. If false, should only try to output as much as can be done without forcing closures.- Returns:
- True if the whole node could be output, ie. neither it nor its children are buffered.
- Throws:
XMLStreamException
-
_forceOutput
Description copied from class:SMOutputtableMethod similar toSMOutputtable._output(SMOutputContext, boolean), except that this method will always succeed in doing the output. Specifically, it will force all buffered nodes to be unbuffered, and then output.- Specified by:
_forceOutputin classSMOutputContainer- Throws:
XMLStreamException
-
_childReleased
Description copied from class:SMOutputContainerMethod called by a child, when it is released and neither is or contains any buffered entities. This should indicate that it can be output unless one of its parents or preceding siblings is buffered. Container is expected to update its own state, and then inform its own parent (if necesary) about release; this may cascade output from parents up the container stack.- Specified by:
_childReleasedin classSMOutputContainer- Parameters:
child- Child node that now neither is nor contains any buffered nodes.- Throws:
XMLStreamException
-
_canOutputNewChild
Description copied from class:SMOutputContainerMethod called to figure out if we can just output a newly added child, without any buffering. It will request container to close and output all non-buffered children it has, if any; and indicate whether it was fully succesful or not.- Specified by:
_canOutputNewChildin classSMOutputContainer- Returns:
- True if all children (if any) were completely output; false if there was at least one buffered child that couldn't be output.
- Throws:
XMLStreamException
-
getPath
Description copied from class:SMOutputContainerMethod that can be called to get an XPath like description of the relative location of this output node, starting from root. Path will be appended to given StringBuilder.- Specified by:
getPathin classSMOutputContainer
-
closeRoot
Method that HAS to be called when all additions have been done via StaxMate API. Since it is possible that the underlying stream writer may be buffering some parts, it needs to be informed of the closure.Note that the underlying stream is NOT closed as part of this call, just this logical outputter object. If you do want the underlying writer to be closed too, call
closeRootAndWriter()instead.- Throws:
XMLStreamException
-
closeRootAndWriter
- Throws:
XMLStreamException
-
throwIfClosed
private final void throwIfClosed()
-