public abstract class OutputElementBase
extends java.lang.Object
implements javax.xml.namespace.NamespaceContext
One noteworthy feature of the class is that it is designed to allow "short-term recycling", ie. instances can be reused within context of a simple document output. While reuse/recycling of such lightweight object is often useless or even counter productive, here it may be worth using, due to simplicity of the scheme (basically using a very simple free-elements linked list).
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
_defaultNsURI |
protected BijectiveNsMap |
_nsMapping
Mapping of namespace prefixes to URIs and back.
|
protected boolean |
_nsMapShared
True, if
_nsMapping is a shared copy from the parent;
false if a local copy was created (which happens when namespaces
get bound etc). |
protected javax.xml.namespace.NamespaceContext |
_rootNsContext
Namespace context end application may have supplied, and that
(if given) should be used to augment explicitly defined bindings.
|
static int |
PREFIX_MISBOUND |
static int |
PREFIX_OK |
static int |
PREFIX_UNBOUND |
Modifier | Constructor and Description |
---|---|
protected |
OutputElementBase()
Constructor for the virtual root element
|
protected |
OutputElementBase(OutputElementBase parent,
BijectiveNsMap ns) |
Modifier and Type | Method and Description |
---|---|
void |
addPrefix(java.lang.String prefix,
java.lang.String uri) |
java.lang.String |
generateMapping(java.lang.String prefixBase,
java.lang.String uri,
int[] seqArr) |
java.lang.String |
getDefaultNsUri() |
java.lang.String |
getExplicitPrefix(java.lang.String uri)
Method similar to
getPrefix(java.lang.String) , but one that will not accept
the default namespace, only an explicit one. |
abstract java.lang.String |
getNameDesc() |
java.lang.String |
getNamespaceURI(java.lang.String prefix) |
java.lang.String |
getPrefix(java.lang.String uri) |
java.util.Iterator<java.lang.String> |
getPrefixes(java.lang.String uri) |
int |
isPrefixValid(java.lang.String prefix,
java.lang.String nsURI,
boolean isElement)
Method that verifies that passed-in prefix indeed maps to the specified
namespace URI; and depending on how it goes returns a status for
caller.
|
abstract boolean |
isRoot() |
protected void |
relink(OutputElementBase parent)
Method called to reuse a pooled instance.
|
abstract void |
setDefaultNsUri(java.lang.String uri) |
protected abstract void |
setRootNsContext(javax.xml.namespace.NamespaceContext ctxt) |
protected void |
throwOutputError(java.lang.String msg) |
public static final int PREFIX_UNBOUND
public static final int PREFIX_OK
public static final int PREFIX_MISBOUND
protected javax.xml.namespace.NamespaceContext _rootNsContext
protected java.lang.String _defaultNsURI
protected BijectiveNsMap _nsMapping
protected boolean _nsMapShared
_nsMapping
is a shared copy from the parent;
false if a local copy was created (which happens when namespaces
get bound etc).protected OutputElementBase()
protected OutputElementBase(OutputElementBase parent, BijectiveNsMap ns)
protected void relink(OutputElementBase parent)
protected abstract void setRootNsContext(javax.xml.namespace.NamespaceContext ctxt)
public abstract boolean isRoot()
public abstract java.lang.String getNameDesc()
public final java.lang.String getDefaultNsUri()
public final java.lang.String getExplicitPrefix(java.lang.String uri)
getPrefix(java.lang.String)
, but one that will not accept
the default namespace, only an explicit one. Usually used when
trying to find a prefix for attributes.public final int isPrefixValid(java.lang.String prefix, java.lang.String nsURI, boolean isElement) throws javax.xml.stream.XMLStreamException
isElement
- If true, rules for the default NS are those of elements
(ie. empty prefix can map to non-default namespace); if false,
rules are those of attributes (only non-default prefix can map to
a non-default namespace).javax.xml.stream.XMLStreamException
- True if default (no) prefix is allowed to
match a non-default URI (elements); false if not (attributes)public abstract void setDefaultNsUri(java.lang.String uri)
public final java.lang.String generateMapping(java.lang.String prefixBase, java.lang.String uri, int[] seqArr)
public final void addPrefix(java.lang.String prefix, java.lang.String uri)
public final java.lang.String getNamespaceURI(java.lang.String prefix)
getNamespaceURI
in interface javax.xml.namespace.NamespaceContext
public final java.lang.String getPrefix(java.lang.String uri)
getPrefix
in interface javax.xml.namespace.NamespaceContext
public final java.util.Iterator<java.lang.String> getPrefixes(java.lang.String uri)
getPrefixes
in interface javax.xml.namespace.NamespaceContext
protected final void throwOutputError(java.lang.String msg) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException