public final class NamespaceContextImpl extends Object implements NamespaceContext2
This class is also used to keep track of tag names for each element for the marshaller (for the performance reason.)
Modifier and Type | Class and Description |
---|---|
class |
NamespaceContextImpl.Element
This model of namespace declarations maintain the following invariants.
|
Modifier and Type | Field and Description |
---|---|
boolean |
collectionMode
True to allow new URIs to be declared.
|
Constructor and Description |
---|
NamespaceContextImpl(XMLSerializer owner) |
Modifier and Type | Method and Description |
---|---|
int |
count()
Number of total bindings declared.
|
String |
declareNamespace(String namespaceUri,
String preferedPrefix,
boolean requirePrefix)
Declares a new namespace binding within the current context.
|
int |
declareNsUri(String uri,
String preferedPrefix,
boolean requirePrefix)
Returns the prefix index to the specified URI.
|
int |
force(String uri,
String prefix)
Forcibly make a namespace declaration in effect.
|
NamespaceContextImpl.Element |
getCurrent() |
String |
getNamespaceURI(int prefixIndex) |
String |
getNamespaceURI(String prefix)
Gets the namespace URI that is bound to the specified prefix.
|
String |
getPrefix(int prefixIndex)
Gets the prefix from a prefix index.
|
String |
getPrefix(String uri)
Returns the prefix of the specified URI,
or null if none exists.
|
Iterator<String> |
getPrefixes(String uri) |
int |
getPrefixIndex(String uri)
Returns the prefix index of the specified URI.
|
NamespacePrefixMapper |
getPrefixMapper() |
int |
put(String uri,
String prefix)
Puts this new binding into the declared prefixes list
without doing any duplicate check.
|
void |
reset() |
void |
setPrefixMapper(NamespacePrefixMapper mapper) |
public boolean collectionMode
public NamespaceContextImpl(XMLSerializer owner)
public void setPrefixMapper(NamespacePrefixMapper mapper)
public NamespacePrefixMapper getPrefixMapper()
public void reset()
public int declareNsUri(String uri, String preferedPrefix, boolean requirePrefix)
public int force(@NotNull String uri, @NotNull String prefix)
NamespaceContext2
force
in interface NamespaceContext2
public int put(@NotNull String uri, @Nullable String prefix)
Most of the time declareNamespace(String, String, boolean)
shall be used.
public NamespaceContextImpl.Element getCurrent()
public int getPrefixIndex(String uri)
public String getPrefix(int prefixIndex)
public String getNamespaceURI(int prefixIndex)
public String getNamespaceURI(String prefix)
getNamespaceURI
in interface NamespaceContext
public String getPrefix(String uri)
getPrefix
in interface NamespaceContext
public Iterator<String> getPrefixes(String uri)
getPrefixes
in interface NamespaceContext
public String declareNamespace(String namespaceUri, String preferedPrefix, boolean requirePrefix)
NamespaceContext2
The prefix is automatically assigned by MarshallingContext. If a given namespace URI is already declared, nothing happens.
It is NOT an error to declare the same namespace URI more than once.
For marshalling to work correctly, all namespace bindings for an element must be declared between its startElement method and its endAttributes event. Calling the same method with the same parameter between the endAttributes and the endElement returns the same prefix.
declareNamespace
in interface NamespaceContext2
preferedPrefix
- If the caller has any particular preference to the
prefix, pass that as a parameter. The callee will try
to honor it. Set null if there's no particular preference.requirePrefix
- If this parameter is true, this method must assign a prefix
to this namespace, even if it's already bound to the default
namespace. IOW, this method will never return null if this
flag is true. This functionality is necessary to declare
namespace URI used for attribute names.public int count()
Copyright © 2017 JBoss by Red Hat. All rights reserved.