com.sun.xml.bind.v2.runtime.output
Class XmlOutputAbstractImpl

java.lang.Object
  extended by com.sun.xml.bind.v2.runtime.output.XmlOutputAbstractImpl
All Implemented Interfaces:
XmlOutput
Direct Known Subclasses:
ForkXmlOutput, MTOMXmlOutput, SAXOutput, UTF8XmlOutput, XMLEventWriterOutput, XMLStreamWriterOutput

public abstract class XmlOutputAbstractImpl
extends java.lang.Object
implements XmlOutput

Abstract implementation of XmlOutput Implements the optimal methods, where defer to the non-optimal methods.


Field Summary
protected  NamespaceContextImpl nsContext
          Set by the marshaller before the start tag is written for the root element.
protected  int[] nsUriIndex2prefixIndex
          The conversion table from the namespace URI index to prefix index.
protected  XMLSerializer serializer
           
 
Constructor Summary
XmlOutputAbstractImpl()
           
 
Method Summary
abstract  void attribute(int prefix, java.lang.String localName, java.lang.String value)
           
 void attribute(Name name, java.lang.String value)
           
abstract  void beginStartTag(int prefix, java.lang.String localName)
           
 void beginStartTag(Name name)
          Writes a start tag.
 void endDocument(boolean fragment)
          Called at the very end.
abstract  void endStartTag()
           
abstract  void endTag(int prefix, java.lang.String localName)
           
 void endTag(Name name)
           
 void startDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext)
          Called at the very beginning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.xml.bind.v2.runtime.output.XmlOutput
text, text
 

Field Detail

nsUriIndex2prefixIndex

protected int[] nsUriIndex2prefixIndex
The conversion table from the namespace URI index to prefix index. This array is shared with XMLSerializer and is updated by it automatically. This allows Name.nsUriIndex to be converted to prefix index (for NamespaceContextImpl) quickly.


nsContext

protected NamespaceContextImpl nsContext
Set by the marshaller before the start tag is written for the root element.


serializer

protected XMLSerializer serializer
Constructor Detail

XmlOutputAbstractImpl

public XmlOutputAbstractImpl()
Method Detail

startDocument

public void startDocument(XMLSerializer serializer,
                          boolean fragment,
                          int[] nsUriIndex2prefixIndex,
                          NamespaceContextImpl nsContext)
                   throws java.io.IOException,
                          org.xml.sax.SAXException,
                          javax.xml.stream.XMLStreamException
Called at the very beginning.

Specified by:
startDocument in interface XmlOutput
Parameters:
serializer - the XMLSerializer that coordinates this whole marshalling episode.
fragment - true if we are marshalling a fragment.
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.stream.XMLStreamException

endDocument

public void endDocument(boolean fragment)
                 throws java.io.IOException,
                        org.xml.sax.SAXException,
                        javax.xml.stream.XMLStreamException
Called at the very end.

Specified by:
endDocument in interface XmlOutput
Parameters:
fragment - false if we are writing the whole document.
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.stream.XMLStreamException

beginStartTag

public void beginStartTag(Name name)
                   throws java.io.IOException,
                          javax.xml.stream.XMLStreamException
Writes a start tag.

At this point nsContext holds namespace declarations needed for this new element.

This method is used for writing tags that are indexed.

Specified by:
beginStartTag in interface XmlOutput
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException

beginStartTag

public abstract void beginStartTag(int prefix,
                                   java.lang.String localName)
                            throws java.io.IOException,
                                   javax.xml.stream.XMLStreamException
Specified by:
beginStartTag in interface XmlOutput
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException

attribute

public void attribute(Name name,
                      java.lang.String value)
               throws java.io.IOException,
                      javax.xml.stream.XMLStreamException
Specified by:
attribute in interface XmlOutput
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException

attribute

public abstract void attribute(int prefix,
                               java.lang.String localName,
                               java.lang.String value)
                        throws java.io.IOException,
                               javax.xml.stream.XMLStreamException
Specified by:
attribute in interface XmlOutput
Parameters:
prefix - -1 if this attribute does not have a prefix (this handling differs from that of elements.)
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException

endStartTag

public abstract void endStartTag()
                          throws java.io.IOException,
                                 org.xml.sax.SAXException
Specified by:
endStartTag in interface XmlOutput
Throws:
java.io.IOException
org.xml.sax.SAXException

endTag

public void endTag(Name name)
            throws java.io.IOException,
                   org.xml.sax.SAXException,
                   javax.xml.stream.XMLStreamException
Specified by:
endTag in interface XmlOutput
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.stream.XMLStreamException

endTag

public abstract void endTag(int prefix,
                            java.lang.String localName)
                     throws java.io.IOException,
                            org.xml.sax.SAXException,
                            javax.xml.stream.XMLStreamException
Specified by:
endTag in interface XmlOutput
Throws:
java.io.IOException
org.xml.sax.SAXException
javax.xml.stream.XMLStreamException