Method from org.xml.sax.helpers.NamespaceSupport$Context Detail: |
void clear() {
parent = null;
prefixTable = null;
uriTable = null;
elementNameTable = null;
attributeNameTable = null;
defaultNS = null;
}
Makes associated state become collectible,
invalidating this context.
#setParent must be called before
this context may be used again. |
void declarePrefix(String prefix,
String uri) {
// Lazy processing...
// if (!declsOK)
// throw new IllegalStateException (
// "can't declare any more prefixes in this context");
if (!declSeen) {
copyTables();
}
if (declarations == null) {
declarations = new Vector();
}
prefix = prefix.intern();
uri = uri.intern();
if ("".equals(prefix)) {
if ("".equals(uri)) {
defaultNS = null;
} else {
defaultNS = uri;
}
} else {
prefixTable.put(prefix, uri);
uriTable.put(uri, prefix); // may wipe out another prefix
}
declarations.addElement(prefix);
}
Declare a Namespace prefix for this context. |
Enumeration getDeclaredPrefixes() {
if (declarations == null) {
return EMPTY_ENUMERATION;
} else {
return declarations.elements();
}
}
Return an enumeration of prefixes declared in this context. |
String getPrefix(String uri) {
if (uriTable == null) {
return null;
} else {
return (String)uriTable.get(uri);
}
}
Look up one of the prefixes associated with a URI in this context.
Since many prefixes may be mapped to the same URI,
the return value may be unreliable. |
Enumeration getPrefixes() {
if (prefixTable == null) {
return EMPTY_ENUMERATION;
} else {
return prefixTable.keys();
}
}
Return an enumeration of all prefixes currently in force.
The default prefix, if in force, is not
returned, and will have to be checked for separately. |
String getURI(String prefix) {
if ("".equals(prefix)) {
return defaultNS;
} else if (prefixTable == null) {
return null;
} else {
return (String)prefixTable.get(prefix);
}
}
Look up the URI associated with a prefix in this context. |
String[] processName(String qName,
boolean isAttribute) {
String name[];
Hashtable table;
// Select the appropriate table.
if (isAttribute) {
table = attributeNameTable;
} else {
table = elementNameTable;
}
// Start by looking in the cache, and
// return immediately if the name
// is already known in this content
name = (String[])table.get(qName);
if (name != null) {
return name;
}
// We haven't seen this name in this
// context before. Maybe in the parent
// context, but we can't assume prefix
// bindings are the same.
name = new String[3];
name[2] = qName.intern();
int index = qName.indexOf(':');
// No prefix.
if (index == -1) {
if (isAttribute) {
if (qName == "xmlns" && namespaceDeclUris)
name[0] = NSDECL;
else
name[0] = "";
} else if (defaultNS == null) {
name[0] = "";
} else {
name[0] = defaultNS;
}
name[1] = name[2];
}
// Prefix
else {
String prefix = qName.substring(0, index);
String local = qName.substring(index+1);
String uri;
if ("".equals(prefix)) {
uri = defaultNS;
} else {
uri = (String)prefixTable.get(prefix);
}
if (uri == null
|| (!isAttribute && "xmlns".equals (prefix))) {
return null;
}
name[0] = uri;
name[1] = local.intern();
}
// Save in the cache for future use.
// (Could be shared with parent context...)
table.put(name[2], name);
return name;
}
Process an XML qualified name in this context. |
void setParent(Context parent) {
this.parent = parent;
declarations = null;
prefixTable = parent.prefixTable;
uriTable = parent.uriTable;
elementNameTable = parent.elementNameTable;
attributeNameTable = parent.attributeNameTable;
defaultNS = parent.defaultNS;
declSeen = false;
}
(Re)set the parent of this Namespace context.
The context must either have been freshly constructed,
or must have been cleared. |