## org.jibx.runtime.impl
Class XMLWriterNamespaceBase

    java.lang.Object
      org.jibx.runtime.impl.XMLWriterNamespaceBase

All Implemented Interfaces:
  IXMLWriter

Direct Known Subclasses:
  JDOMWriter, StAXWriter, XMLWriterBase

    public abstract class XMLWriterNamespaceBase

extends java.lang.Object
implements IXMLWriter

Base implementation of XML writer interface namespace handling. This tracks only the namespace declarations and the element nesting depth. It can be used as a base class for all forms of output.

Version:
  1.0
Author:
  Dennis M. Sosnoski

Constructor Summary
`XMLWriterNamespaceBase(java.lang.String[] uris)` Constructor.
`XMLWriterNamespaceBase(XMLWriterNamespaceBase base, java.lang.String[] uris)` Copy constructor.

Method Summary
`java.lang.String[][]` `getExtensionNamespaces()` Get extension namespace URIs added to those in mapping.
`int` `getNamespaceCount()` Get the number of namespaces currently defined.
`java.lang.String` `getNamespacePrefix(int index)` Get current prefix defined for namespace.
`java.lang.String[]` `getNamespaces()` Get namespace URIs for mapping.
`java.lang.String` `getNamespaceUri(int index)` Get URI for namespace.
`int` `getNestingDepth()` Get the current element nesting depth.
`int` `getPrefixIndex(java.lang.String prefix)` Get index of namespace mapped to prefix.
`int[]` `openNamespaces(int[] nums, java.lang.String[] prefs)` Open the specified namespaces.
`void` `popExtensionNamespaces()` Remove extension namespace URIs.
`void` `pushExtensionNamespaces(java.lang.String[] uris)` Append extension namespace URIs to those in mapping.
`void` `reset()` Reset to initial state for reuse.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jibx.runtime.IXMLWriter
`addAttribute, close, closeEmptyTag, closeStartTag, endTag, flush, indent, setIndentSpaces, startTagClosed, startTagNamespaces, startTagOpen, writeCData, writeComment, writeDocType, writeEntityRef, writePI, writeTextContent, writeXMLDecl`

Constructor Detail

### XMLWriterNamespaceBase

    public XMLWriterNamespaceBase(java.lang.String[] uris)

  Constructor.

  Parameters:
    `uris` - ordered array of URIs for namespaces used in document (must be constant; the value in position 0 must always be the empty string "", and the value in position 1 must always be the XML namespace "http://www.w3.org/XML/1998/namespace")

### XMLWriterNamespaceBase

    public XMLWriterNamespaceBase(XMLWriterNamespaceBase base,
                                  java.lang.String[] uris)

  Copy constructor. This initializes the extension namespace information from an existing instance.

  Parameters:
    `base` - existing instance
    `uris` - ordered array of URIs for namespaces used in document

Method Detail

### openNamespaces

    public int[] openNamespaces(int[] nums,
                                java.lang.String[] prefs)
                         throws java.io.IOException

  Open the specified namespaces. Previously active namespace declarations are not duplicated.

  Specified by:
    `openNamespaces` in interface `IXMLWriter`
  Parameters:
    `nums` - array of namespace indexes defined by this element (must be constant, reference is kept until end of element)
    `prefs` - array of namespace prefixes mapped by this element (no `null` values, use "" for default namespace declaration)
  Returns:
    array of indexes for namespaces not previously active (the ones actually needing to be declared, in the case of text output)
  Throws:
    `java.io.IOException` - on error writing to document

### getNestingDepth

    public final int getNestingDepth()

  Get the current element nesting depth. Elements are only counted in the depth returned when they're officially open - after the start tag has been output and before the end tag has been output.

  Specified by:
    `getNestingDepth` in interface `IXMLWriter`
  Returns:
    number of nested elements at current point in output

### getNamespaceCount

    public final int getNamespaceCount()

  Get the number of namespaces currently defined. This is equivalent to the index of the next extension namespace added.

  Specified by:
    `getNamespaceCount` in interface `IXMLWriter`
  Returns:
    namespace count

### reset

    public void reset()

  Reset to initial state for reuse. Subclasses overriding this method need to call this base class implementation during their processing.

  Specified by:
    `reset` in interface `IXMLWriter`

### getNamespaces

    public final java.lang.String[] getNamespaces()

  Get namespace URIs for mapping. This gets the full ordered array of namespaces known in the binding used for this marshalling, where the index number of each namespace URI is the namespace index used to lookup the prefix when marshalling a name in that namespace. The returned array must not be modified.

  Specified by:
    `getNamespaces` in interface `IXMLWriter`
  Returns:
    array of namespaces

### getNamespaceUri

    public final java.lang.String getNamespaceUri(int index)

  Get URI for namespace.

  Specified by:
    `getNamespaceUri` in interface `IXMLWriter`
  Parameters:
    `index` - namespace URI index number
  Returns:
    namespace URI text, or `null` if the namespace index is invalid

### getNamespacePrefix

    public final java.lang.String getNamespacePrefix(int index)

  Get current prefix defined for namespace.

  Specified by:
    `getNamespacePrefix` in interface `IXMLWriter`
  Parameters:
    `index` - namespace URI index number
  Returns:
    current prefix text, or `null` if the namespace is not currently mapped

### getPrefixIndex

    public final int getPrefixIndex(java.lang.String prefix)

  Get index of namespace mapped to prefix. This can be an expensive operation with time proportional to the number of namespaces defined, so it should be used with care.

  Specified by:
    `getPrefixIndex` in interface `IXMLWriter`
  Parameters:
    `prefix` - text to match (non-`null`, use "" for default prefix)
  Returns:
    index namespace URI index number mapped to prefix

### pushExtensionNamespaces

    public void pushExtensionNamespaces(java.lang.String[] uris)

  Append extension namespace URIs to those in mapping.

  Specified by:
    `pushExtensionNamespaces` in interface `IXMLWriter`
  Parameters:
    `uris` - namespace URIs to extend those in mapping

### popExtensionNamespaces

    public void popExtensionNamespaces()

  Remove extension namespace URIs. This removes the last set of extension namespaces pushed using `pushExtensionNamespaces(java.lang.String[])`.

  Specified by:
    `popExtensionNamespaces` in interface `IXMLWriter`

### getExtensionNamespaces

    public final java.lang.String[][] getExtensionNamespaces()

  Get extension namespace URIs added to those in mapping. This gets the current set of extension definitions. The returned arrays must not be modified.

  Specified by:
    `getExtensionNamespaces` in interface `IXMLWriter`
  Returns:
    array of arrays of extension namespaces (`null` if none)

Project Web Site |