org.codehaus.staxmate.out
Class SMOutputElement

java.lang.Object
  extended by org.codehaus.staxmate.out.SMOutputtable
      extended by org.codehaus.staxmate.out.SMOutputContainer
          extended by org.codehaus.staxmate.out.SMOutputElement
Direct Known Subclasses:
SMBufferedElement

public class SMOutputElement
extends SMOutputContainer

Output class that models an outputtable XML element.


Field Summary
protected  java.lang.String mLocalName
          Local name of the element, name without preceding prefix or colon (in namespace mode).
protected  SMNamespace mNs
          Namespace of this element.
protected  int mOutputState
           
protected  SMNamespace mParentDefaultNs
          Namespace that was bound as the default namespace in the context where this element gets output.
protected  int mParentNsCount
          Number of explicitly bound namespaces parent element has (or for root elements 0).
protected static int OUTPUT_ATTRS
           
protected static int OUTPUT_CHILDREN
           
protected static int OUTPUT_CLOSED
           
protected static int OUTPUT_NONE
           
 
Fields inherited from class org.codehaus.staxmate.out.SMOutputtable
mNext
 
Constructor Summary
protected SMOutputElement(SMOutputContext ctxt, java.lang.String localName, SMNamespace ns)
           
 
Method Summary
 void addAttribute(SMNamespace ns, java.lang.String localName, int value)
          Convenience method to use for adding attributes with integer values
 void addAttribute(SMNamespace ns, java.lang.String localName, java.lang.String value)
           
 void addAttribute(java.lang.String localName, java.lang.String value)
          Convenience method for attributes that do not belong to a namespace (no prefix)
 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  boolean doOutput(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.
protected  void doWriteEndElement()
           
protected  void doWriteStartElement()
           
protected  void forceOutput(SMOutputContext ctxt)
          Method similar to SMOutputtable.doOutput(org.codehaus.staxmate.out.SMOutputContext, boolean), except that this method will always succeed in doing the output.
 java.lang.String getLocalName()
           
 SMNamespace getNamespace()
           
 void getPath(java.lang.StringBuilder sb)
           
 void linkParent(SMOutputContainer parent, boolean blocked)
           
protected  void throwClosedForAttrs()
           
 
Methods inherited from class org.codehaus.staxmate.out.SMOutputContainer
addAndReleaseBuffered, addBuffered, addCData, addCData, addCharacters, addCharacters, addCharacters, addComment, addElement, addElement, addEntityRef, addProcessingInstruction, closeAllButLastChild, closeAndOutputChildren, createBufferedElement, createBufferedFragment, forceChildOutput, getContext, getNamespace, getNamespace, getParent, getPath, linkNewChild, setIndentation, throwBuffered, throwClosed, throwRelinking
 
Methods inherited from class org.codehaus.staxmate.out.SMOutputtable
getNext, linkNext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OUTPUT_NONE

protected static final int OUTPUT_NONE
See Also:
Constant Field Values

OUTPUT_ATTRS

protected static final int OUTPUT_ATTRS
See Also:
Constant Field Values

OUTPUT_CHILDREN

protected static final int OUTPUT_CHILDREN
See Also:
Constant Field Values

OUTPUT_CLOSED

protected static final int OUTPUT_CLOSED
See Also:
Constant Field Values

mLocalName

protected final java.lang.String mLocalName
Local name of the element, name without preceding prefix or colon (in namespace mode). In non-namespace mode fully-qualified name.


mNs

protected final SMNamespace mNs
Namespace of this element.

Note: can never be null -- event the default (empty) namespace is presented by a global shared namespace instance.


mOutputState

protected int mOutputState

mParentDefaultNs

protected SMNamespace mParentDefaultNs
Namespace that was bound as the default namespace in the context where this element gets output. This is generally just stored here to be able to write the end element matching start element, since it's SMOutputContext that handles actual namespace binding for output. This is either the default declared namespace of an ancestor element, or if none exists, the default namespace of the root (either the empty namespace, or one found via NamespaceContext.

Note: can never be null -- event the default (empty) namespace is presented by a global shared namespace instance.


mParentNsCount

protected int mParentNsCount
Number of explicitly bound namespaces parent element has (or for root elements 0). Stored for SMOutputContext during time element is open; needed for closing namespace scopes appropriately.

Constructor Detail

SMOutputElement

protected SMOutputElement(SMOutputContext ctxt,
                          java.lang.String localName,
                          SMNamespace ns)
Method Detail

getLocalName

public java.lang.String getLocalName()

getNamespace

public SMNamespace getNamespace()

linkParent

public void linkParent(SMOutputContainer parent,
                       boolean blocked)
                throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

addAttribute

public void addAttribute(SMNamespace ns,
                         java.lang.String localName,
                         java.lang.String value)
                  throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

addAttribute

public void addAttribute(java.lang.String localName,
                         java.lang.String value)
                  throws javax.xml.stream.XMLStreamException
Convenience method for attributes that do not belong to a namespace (no prefix)

Throws:
javax.xml.stream.XMLStreamException

addAttribute

public void addAttribute(SMNamespace ns,
                         java.lang.String localName,
                         int value)
                  throws javax.xml.stream.XMLStreamException
Convenience method to use for adding attributes with integer values

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 class SMOutputContainer
Parameters:
child - Child node that now neither is nor contains any buffered nodes.
Throws:
javax.xml.stream.XMLStreamException

doOutput

protected boolean doOutput(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:
doOutput in class SMOutputContainer
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 to SMOutputtable.doOutput(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 class SMOutputContainer
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 class SMOutputContainer
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)
Specified by:
getPath in class SMOutputContainer

doWriteStartElement

protected void doWriteStartElement()
                            throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

doWriteEndElement

protected void doWriteEndElement()
                          throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

throwClosedForAttrs

protected void throwClosedForAttrs()