Package de.aristaflow.adept2.util.xml
Class NamespaceLookup
- java.lang.Object
-
- de.aristaflow.adept2.util.xml.NamespaceLookup
-
- All Implemented Interfaces:
NamespaceContext
public class NamespaceLookup extends Object implements NamespaceContext
A resolver looking up the namespace in a map of provided namespaces and in a specificDocument
.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
DEFAULT_VALUE
The default value returned in case the map does not contain a key.protected ConcurrentMap<String,String>
ns2Pref
Additional prefixes in a map indexed by the corresponding namespace.protected ConcurrentMap<String,String>
pref2Ns
Additional namespaces in a map indexed by the corresponding prefix.protected Document
sourceDocument
The document in which to lookup the namespace.
-
Constructor Summary
Constructors Constructor Description NamespaceLookup(Document document)
Creates a newNamespaceContext
looking up namespaces in the designatedDocument
or additionally set namespaces.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNamespace(String prefix, String namespace)
Adds the designated prefix and namespace additionally to the document.String
getNamespaceURI(String prefix)
String
getPrefix(String namespaceURI)
Iterator
getPrefixes(String namespaceURI)
-
-
-
Field Detail
-
DEFAULT_VALUE
protected static final String DEFAULT_VALUE
The default value returned in case the map does not contain a key.- See Also:
- Constant Field Values
-
pref2Ns
protected final ConcurrentMap<String,String> pref2Ns
Additional namespaces in a map indexed by the corresponding prefix. This takes precedence oversourceDocument
.
-
ns2Pref
protected final ConcurrentMap<String,String> ns2Pref
Additional prefixes in a map indexed by the corresponding namespace. This is the reverse mapping ofpref2Ns
. It takes precedence oversourceDocument
.
-
sourceDocument
protected final Document sourceDocument
The document in which to lookup the namespace.
-
-
Constructor Detail
-
NamespaceLookup
public NamespaceLookup(Document document)
Creates a newNamespaceContext
looking up namespaces in the designatedDocument
or additionally set namespaces.- Parameters:
document
- The document in which to lookup the namespace.
-
-
Method Detail
-
addNamespace
public void addNamespace(String prefix, String namespace)
Adds the designated prefix and namespace additionally to the document. This takes precedence over the document.- Parameters:
prefix
- The prefix which to additionally add.namespace
- The namespace which to additionally add.
-
getNamespaceURI
public String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURI
in interfaceNamespaceContext
-
getPrefix
public String getPrefix(String namespaceURI)
- Specified by:
getPrefix
in interfaceNamespaceContext
-
getPrefixes
public Iterator getPrefixes(String namespaceURI)
- Specified by:
getPrefixes
in interfaceNamespaceContext
-
-