Package org.codehaus.staxmate.out
Class SMBufferedFragment
- java.lang.Object
-
- org.codehaus.staxmate.out.SMOutputtable
-
- org.codehaus.staxmate.out.SMOutputContainer
-
- org.codehaus.staxmate.out.SMBufferedFragment
-
- All Implemented Interfaces:
SMBufferable
public final class SMBufferedFragment extends SMOutputContainer implements SMBufferable
Buffered fragment; starts its life buffered, so that its content are not automatically written to the underlying stream, but only when buffered instance is released. Once released, can not be buffered again.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_state
All instances are initially buffered; state will be changed when instance is released (and further on with other changes)protected static int
LAST_BLOCKED
protected static int
LAST_BUFFERED
protected static int
STATE_BLOCKED
protected static int
STATE_BUFFERED
protected static int
STATE_BUFFERED_AND_BLOCKED
protected static int
STATE_CLOSED
protected static int
STATE_OPEN
-
Fields inherited from class org.codehaus.staxmate.out.SMOutputContainer
_context, _firstChild, _lastChild, _parent
-
Fields inherited from class org.codehaus.staxmate.out.SMOutputtable
_next
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SMBufferedFragment(SMOutputContext ctxt)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
_canOutputNewChild()
Method 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(org.codehaus.staxmate.out.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.void
getPath(java.lang.StringBuilder sb)
Method that can be called to get an XPath like description of the relative location of this output node, starting from root.boolean
isBuffered()
void
linkParent(SMOutputContainer parent, boolean blocked)
Method called by a container when bufferable item is linked as its child.void
release()
Method called to signal that the node need not be buffered any more (if not required to do so by parent/children restrictions)-
Methods inherited from class org.codehaus.staxmate.out.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, setIndentation
-
Methods inherited from class org.codehaus.staxmate.out.SMOutputtable
_linkNext, getNext
-
-
-
-
Field Detail
-
STATE_BUFFERED_AND_BLOCKED
protected static final int STATE_BUFFERED_AND_BLOCKED
- See Also:
- Constant Field Values
-
STATE_BUFFERED
protected static final int STATE_BUFFERED
- See Also:
- Constant Field Values
-
STATE_BLOCKED
protected static final int STATE_BLOCKED
- See Also:
- Constant Field Values
-
STATE_OPEN
protected static final int STATE_OPEN
- See Also:
- Constant Field Values
-
STATE_CLOSED
protected static final int STATE_CLOSED
- See Also:
- Constant Field Values
-
LAST_BUFFERED
protected static final int LAST_BUFFERED
- See Also:
- Constant Field Values
-
LAST_BLOCKED
protected static final int LAST_BLOCKED
- See Also:
- Constant Field Values
-
_state
protected int _state
All instances are initially buffered; state will be changed when instance is released (and further on with other changes)
-
-
Constructor Detail
-
SMBufferedFragment
protected SMBufferedFragment(SMOutputContext ctxt)
-
-
Method Detail
-
isBuffered
public boolean isBuffered()
- Specified by:
isBuffered
in interfaceSMBufferable
- Returns:
- True if this object is still buffered; false if not
-
linkParent
public void linkParent(SMOutputContainer parent, boolean blocked) throws javax.xml.stream.XMLStreamException
Description copied from interface:SMBufferable
Method called by a container when bufferable item is linked as its child. It should not only add parent linkage, but also do any output necessary, if this item is not buffered or blocked.- Specified by:
linkParent
in interfaceSMBufferable
- Parameters:
parent
- Container to attach bufferable instance underblocked
- If true, parent output is blocked (and as the result so is bufferable's); if false, parent is (and will remain) unblocked.- Throws:
javax.xml.stream.XMLStreamException
-
release
public void release() throws javax.xml.stream.XMLStreamException
Description copied from interface:SMBufferable
Method called to signal that the node need not be buffered any more (if not required to do so by parent/children restrictions)- Specified by:
release
in interfaceSMBufferable
- Throws:
javax.xml.stream.XMLStreamException
-
_childReleased
protected void _childReleased(SMOutputtable child) throws javax.xml.stream.XMLStreamException
Description copied from class:SMOutputContainer
Method 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:
_childReleased
in classSMOutputContainer
- Parameters:
child
- Child node that now neither is nor contains any buffered nodes.- Throws:
javax.xml.stream.XMLStreamException
-
_output
protected boolean _output(SMOutputContext ctxt, boolean canClose) throws javax.xml.stream.XMLStreamException
Description copied from class:SMOutputtable
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. 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:
_output
in 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:
javax.xml.stream.XMLStreamException
-
_forceOutput
protected void _forceOutput(SMOutputContext ctxt) throws javax.xml.stream.XMLStreamException
Description copied from class:SMOutputtable
Method similar toSMOutputtable._output(org.codehaus.staxmate.out.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:
_forceOutput
in classSMOutputContainer
- Throws:
javax.xml.stream.XMLStreamException
-
_canOutputNewChild
public boolean _canOutputNewChild() throws javax.xml.stream.XMLStreamException
Description copied from class:SMOutputContainer
Method 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:
_canOutputNewChild
in 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:
javax.xml.stream.XMLStreamException
-
getPath
public void getPath(java.lang.StringBuilder sb)
Description copied from class:SMOutputContainer
Method 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:
getPath
in classSMOutputContainer
-
-