Methods Summary |
---|
public boolean | containsPrefix(java.lang.String prefix)Checks whether a binding or unbinding for
the given prefix exists in the context.
// find prefix in current context
for (int i = fNamespaceSize; i > 0; i -= 2) {
if (fNamespace[i - 2] == prefix) {
return true;
}
}
// prefix not found
return false;
|
public boolean | declarePrefix(java.lang.String prefix, java.lang.String uri)
// ignore "xml" and "xmlns" prefixes
if (prefix == XMLSymbols.PREFIX_XML || prefix == XMLSymbols.PREFIX_XMLNS) {
return false;
}
// see if prefix already exists in current context
for (int i = fNamespaceSize; i > fContext[fCurrentContext]; i -= 2) {
if (fNamespace[i - 2] == prefix) {
// REVISIT: [Q] Should the new binding override the
// previously declared binding or should it
// it be ignored? -Ac
// NOTE: The SAX2 "NamespaceSupport" helper allows
// re-bindings with the new binding overwriting
// the previous binding. -Ac
fNamespace[i - 1] = uri;
return true;
}
}
// resize array, if needed
if (fNamespaceSize == fNamespace.length) {
String[] namespacearray = new String[fNamespaceSize * 2];
System.arraycopy(fNamespace, 0, namespacearray, 0, fNamespaceSize);
fNamespace = namespacearray;
}
// bind prefix to uri in current context
fNamespace[fNamespaceSize++] = prefix;
fNamespace[fNamespaceSize++] = uri;
return true;
|
public java.util.Enumeration | getAllPrefixes()
int count = 0;
if (fPrefixes.length < (fNamespace.length/2)) {
// resize prefix array
String[] prefixes = new String[fNamespaceSize];
fPrefixes = prefixes;
}
String prefix = null;
boolean unique = true;
for (int i = 2; i < (fNamespaceSize-2); i += 2) {
prefix = fNamespace[i + 2];
for (int k=0;k<count;k++){
if (fPrefixes[k]==prefix){
unique = false;
break;
}
}
if (unique){
fPrefixes[count++] = prefix;
}
unique = true;
}
return new Prefixes(fPrefixes, count);
|
public java.lang.String | getDeclaredPrefixAt(int index)
return fNamespace[fContext[fCurrentContext] + index * 2];
|
public int | getDeclaredPrefixCount()
return (fNamespaceSize - fContext[fCurrentContext]) / 2;
|
public java.lang.String | getPrefix(java.lang.String uri)
// find uri in current context
for (int i = fNamespaceSize; i > 0; i -= 2) {
if (fNamespace[i - 1] == uri) {
if (getURI(fNamespace[i - 2]) == uri)
return fNamespace[i - 2];
}
}
// uri not found
return null;
|
public java.lang.String | getURI(java.lang.String prefix)
// find prefix in current context
for (int i = fNamespaceSize; i > 0; i -= 2) {
if (fNamespace[i - 2] == prefix) {
return fNamespace[i - 1];
}
}
// prefix not found
return null;
|
public void | popContext()
fNamespaceSize = fContext[fCurrentContext--];
|
public void | pushContext()
// extend the array, if necessary
if (fCurrentContext + 1 == fContext.length) {
int[] contextarray = new int[fContext.length * 2];
System.arraycopy(fContext, 0, contextarray, 0, fContext.length);
fContext = contextarray;
}
// push context
fContext[++fCurrentContext] = fNamespaceSize;
|
public void | reset()
// reset namespace and context info
fNamespaceSize = 0;
fCurrentContext = 0;
fContext[fCurrentContext] = fNamespaceSize;
// bind "xml" prefix to the XML uri
fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XML;
fNamespace[fNamespaceSize++] = NamespaceContext.XML_URI;
// bind "xmlns" prefix to the XMLNS uri
fNamespace[fNamespaceSize++] = XMLSymbols.PREFIX_XMLNS;
fNamespace[fNamespaceSize++] = NamespaceContext.XMLNS_URI;
++fCurrentContext;
|