Package com.ctc.wstx.sw
Class OutputElementBase
java.lang.Object
com.ctc.wstx.sw.OutputElementBase
- All Implemented Interfaces:
NamespaceContext
- Direct Known Subclasses:
DOMOutputElement
,SimpleOutputElement
Class that encapsulates information about a specific element in virtual
output stack for namespace-aware writers.
It provides support for URI-to-prefix mappings as well as namespace
mapping generation.
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).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final BijectiveNsMap
protected String
protected BijectiveNsMap
Mapping of namespace prefixes to URIs and back.protected boolean
True, ifmNsMapping
is a shared copy from the parent; false if a local copy was created (which happens when namespaces get bound etc).protected NamespaceContext
Namespace context end application may have supplied, and that (if given) should be used to augment explicitly defined bindings.static final int
static final int
static final int
protected static final String
protected static final String
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor for the virtual root elementprotected
OutputElementBase
(OutputElementBase parent, BijectiveNsMap ns) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
final String
generateMapping
(String prefixBase, String uri, int[] seqArr) final String
final String
getExplicitPrefix
(String uri) Method similar togetPrefix(java.lang.String)
, but one that will not accept the default namespace, only an explicit one.abstract String
final String
getNamespaceURI
(String prefix) final String
getPrefixes
(String uri) final int
isPrefixValid
(String prefix, 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
(String uri) protected abstract void
protected final void
throwOutputError
(String msg)
-
Field Details
-
PREFIX_UNBOUND
public static final int PREFIX_UNBOUND- See Also:
-
PREFIX_OK
public static final int PREFIX_OK- See Also:
-
PREFIX_MISBOUND
public static final int PREFIX_MISBOUND- See Also:
-
sXmlNsPrefix
- See Also:
-
sXmlNsURI
- See Also:
-
DEFAULT_XML_BINDINGS
-
mRootNsContext
Namespace context end application may have supplied, and that (if given) should be used to augment explicitly defined bindings. -
mDefaultNsURI
-
mNsMapping
Mapping of namespace prefixes to URIs and back.
-
-
Constructor Details
-
OutputElementBase
protected OutputElementBase()Constructor for the virtual root element -
OutputElementBase
-
-
Method Details
-
relink
Method called to reuse a pooled instance. -
setRootNsContext
-
isRoot
public abstract boolean isRoot() -
getNameDesc
- Returns:
- String presentation of the fully-qualified name, in "prefix:localName" format (no URI). Useful for error and debugging messages.
-
getDefaultNsUri
-
getExplicitPrefix
Method similar togetPrefix(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. -
isPrefixValid
public final int isPrefixValid(String prefix, String nsURI, boolean isElement) throws XMLStreamException 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.- Parameters:
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).- Returns:
- PREFIX_OK, if passed-in prefix matches matched-in namespace URI in current scope; PREFIX_UNBOUND if it's not bound to anything, and PREFIX_MISBOUND if it's bound to another URI.
- Throws:
XMLStreamException
- True if default (no) prefix is allowed to match a non-default URI (elements); false if not (attributes)
-
setDefaultNsUri
-
generateMapping
-
addPrefix
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceNamespaceContext
-
getPrefix
- Specified by:
getPrefix
in interfaceNamespaceContext
-
getPrefixes
- Specified by:
getPrefixes
in interfaceNamespaceContext
-
throwOutputError
- Throws:
XMLStreamException
-