|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jibx.runtime.impl.XMLWriterNamespaceBase
public abstract class XMLWriterNamespaceBase
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.
Nested Class Summary | |
---|---|
private static class |
XMLWriterNamespaceBase.DeclarationInfo
Namespace declaration tracking information. |
Field Summary | |
---|---|
private static int[] |
EMPTY_INT_ARRAY
Empty array for default return. |
private java.lang.String[][] |
m_extensionPrefixes
Extension namespace prefixes ( null if not in use). |
private java.lang.String[][] |
m_extensionUris
Extension namespace URIs ( null if not in use). |
private int |
m_namespaceDepth
Depth of top namespace declaration level. |
private java.util.Stack |
m_namespaceStack
Stack of information for namespace declarations. |
private int |
m_nestingDepth
Depth of nested tags. |
protected java.lang.String[] |
m_prefixes
Prefixes currently defined for namespaces. |
protected java.lang.String[] |
m_uris
URIs for namespaces. |
Constructor Summary | |
---|---|
XMLWriterNamespaceBase(java.lang.String[] uris)
Constructor. |
|
XMLWriterNamespaceBase(XMLWriterNamespaceBase base,
java.lang.String[] uris)
Copy constructor. |
Method Summary | |
---|---|
private void |
closeNamespaces()
Ends the current innermost set of nested namespace definitions. |
protected void |
decrementNesting()
Decrement the current nesting depth. |
protected abstract void |
defineNamespace(int index,
java.lang.String prefix)
Report to subclass that namespace has been defined. |
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. |
protected static java.lang.String[][] |
growArray(java.lang.String[][] base,
java.lang.String[] items)
Grow array of array of strings. |
protected void |
incrementNesting()
Increment the current nesting depth. |
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. |
private void |
setNamespacePrefix(int index,
java.lang.String prefix)
Set prefix for namespace. |
protected static java.lang.String[][] |
shrinkArray(java.lang.String[][] base)
Shrink array of array of strings. |
protected abstract void |
undefineNamespace(int index)
Report to subclass that namespace has been undefined. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, 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 |
Field Detail |
---|
private static final int[] EMPTY_INT_ARRAY
protected java.lang.String[] m_uris
protected java.lang.String[] m_prefixes
private int m_nestingDepth
private java.util.Stack m_namespaceStack
private int m_namespaceDepth
private java.lang.String[][] m_extensionUris
null
if not in use).
private java.lang.String[][] m_extensionPrefixes
null
if not in use).
Constructor Detail |
---|
public XMLWriterNamespaceBase(java.lang.String[] uris)
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")public XMLWriterNamespaceBase(XMLWriterNamespaceBase base, java.lang.String[] uris)
base
- existing instanceuris
- ordered array of URIs for namespaces used in documentMethod Detail |
---|
protected abstract void defineNamespace(int index, java.lang.String prefix) throws java.io.IOException
index
- namespace URI index numberprefix
- prefix used for namespace
java.io.IOException
- if error writing to documentprotected abstract void undefineNamespace(int index)
index
- namespace URI index numberprivate void setNamespacePrefix(int index, java.lang.String prefix)
index
- namespace URI index numberpublic int[] openNamespaces(int[] nums, java.lang.String[] prefs) throws java.io.IOException
openNamespaces
in interface IXMLWriter
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)
java.io.IOException
- on error writing to documentprivate void closeNamespaces()
public final int getNestingDepth()
getNestingDepth
in interface IXMLWriter
public final int getNamespaceCount()
getNamespaceCount
in interface IXMLWriter
protected void incrementNesting()
protected void decrementNesting()
public void reset()
reset
in interface IXMLWriter
public final java.lang.String[] getNamespaces()
getNamespaces
in interface IXMLWriter
public final java.lang.String getNamespaceUri(int index)
getNamespaceUri
in interface IXMLWriter
index
- namespace URI index number
null
if the namespace index
is invalidpublic final java.lang.String getNamespacePrefix(int index)
getNamespacePrefix
in interface IXMLWriter
index
- namespace URI index number
null
if the namespace is not
currently mappedpublic final int getPrefixIndex(java.lang.String prefix)
getPrefixIndex
in interface IXMLWriter
prefix
- text to match (non-null
, use "" for default
prefix)
protected static java.lang.String[][] growArray(java.lang.String[][] base, java.lang.String[] items)
base
- array to be grown (null
is treated as zero
length)items
- array of strings to be added at end of base array
protected static java.lang.String[][] shrinkArray(java.lang.String[][] base)
base
- array to be shrunk
null
if
empty)public void pushExtensionNamespaces(java.lang.String[] uris)
pushExtensionNamespaces
in interface IXMLWriter
uris
- namespace URIs to extend those in mappingpublic void popExtensionNamespaces()
pushExtensionNamespaces(java.lang.String[])
.
popExtensionNamespaces
in interface IXMLWriter
public final java.lang.String[][] getExtensionNamespaces()
getExtensionNamespaces
in interface IXMLWriter
null
if
none)
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |