|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.xml.serializer.NamespaceMappings
public class NamespaceMappings
This class keeps track of the currently defined namespaces. Conceptually the prefix/uri/depth triplets are pushed on a stack pushed on a stack. The depth indicates the nesting depth of the element for which the mapping was made.
For example:
When the
| Nested Class Summary | |
|---|---|
(package private) static class |
NamespaceMappings.MappingRecord
Just a little class that ties the 3 fields together into one object, and this simplifies the pushing and popping of namespaces to one push or one pop on one stack rather than on 3 separate stacks. |
private class |
NamespaceMappings.Stack
Rather than using java.util.Stack, this private class provides a minimal subset of methods and is faster because it is not thread-safe. |
| Field Summary | |
|---|---|
private int |
count
This member is continually incremented when new prefixes need to be generated. |
private static java.lang.String |
EMPTYSTRING
|
private java.util.Hashtable |
m_namespaces
Each entry (prefix) in this hashtable points to a Stack of URIs This table maps a prefix (String) to a Stack of NamespaceNodes. |
private NamespaceMappings.Stack |
m_nodeStack
This stack is used as a convenience. |
private static java.lang.String |
XML_PREFIX
|
| Constructor Summary | |
|---|---|
NamespaceMappings()
Default constructor |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
This method makes a clone of this object. |
private NamespaceMappings.Stack |
createPrefixStack(java.lang.String prefix)
A more type-safe way of saving stacks under the m_namespaces Hashtable. |
java.lang.String |
generateNextPrefix()
Generate a new namespace prefix ( ns0, ns1 ...) not used before |
(package private) NamespaceMappings.MappingRecord |
getMappingFromPrefix(java.lang.String prefix)
|
(package private) NamespaceMappings.MappingRecord |
getMappingFromURI(java.lang.String uri)
|
private NamespaceMappings.Stack |
getPrefixStack(java.lang.String prefix)
A more type-safe way to get a stack of prefix mappings from the Hashtable m_namespaces (this is the only method that does the type cast). |
private void |
initNamespaces()
This method initializes the namespace object with appropriate stacks and predefines a few prefix/uri pairs which always exist. |
java.lang.String[] |
lookupAllPrefixes(java.lang.String uri)
Given a namespace uri, get all prefixes bound to the Namespace URI in the current scope. |
java.lang.String |
lookupNamespace(java.lang.String prefix)
Use a namespace prefix to lookup a namespace URI. |
java.lang.String |
lookupPrefix(java.lang.String uri)
Given a namespace uri, and the namespaces mappings for the current element, return the current prefix for that uri. |
(package private) boolean |
popNamespace(java.lang.String prefix)
Undeclare the namespace that is currently pointed to by a given prefix |
(package private) void |
popNamespaces(int elemDepth,
org.xml.sax.ContentHandler saxHandler)
Pop, or undeclare all namespace definitions that are currently declared at the given element depth, or deepter. |
boolean |
pushNamespace(java.lang.String prefix,
java.lang.String uri,
int elemDepth)
Declare a mapping of a prefix to namespace URI at the given element depth. |
(package private) void |
reset()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private int count
private java.util.Hashtable m_namespaces
private NamespaceMappings.Stack m_nodeStack
private static final java.lang.String EMPTYSTRING
private static final java.lang.String XML_PREFIX
| Constructor Detail |
|---|
public NamespaceMappings()
Object.Object()| Method Detail |
|---|
private void initNamespaces()
public java.lang.String lookupNamespace(java.lang.String prefix)
prefix - String the prefix of the namespace
NamespaceMappings.MappingRecord getMappingFromPrefix(java.lang.String prefix)
public java.lang.String lookupPrefix(java.lang.String uri)
uri - the namespace URI to be search for
NamespaceMappings.MappingRecord getMappingFromURI(java.lang.String uri)
boolean popNamespace(java.lang.String prefix)
public boolean pushNamespace(java.lang.String prefix,
java.lang.String uri,
int elemDepth)
prefix - a String with the prefix for a qualified nameuri - a String with the uri to which the prefix is to mapelemDepth - the depth of current declaration
void popNamespaces(int elemDepth,
org.xml.sax.ContentHandler saxHandler)
elemDepth - the element depth for which mappings declared at this
depth or deeper will no longer be validsaxHandler - The ContentHandler to notify of any endPrefixMapping()
calls. This parameter can be null.public java.lang.String generateNextPrefix()
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionfinal void reset()
private NamespaceMappings.Stack getPrefixStack(java.lang.String prefix)
private NamespaceMappings.Stack createPrefixStack(java.lang.String prefix)
public java.lang.String[] lookupAllPrefixes(java.lang.String uri)
uri - the namespace URI to be search for
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||