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 context
for (int i = fNamespaceSize; i > 0; i -= 2) {
if (fNamespace[i - 2] == prefix) {
return true;
}
}
// prefix not found
return false;
|
public boolean | containsPrefixInCurrentContext(java.lang.String prefix)Checks whether a binding or unbinding for
the given prefix exists in the current context.
// find prefix in current context
for (int i = fContext[fCurrentContext]; i < fNamespaceSize; i += 2) {
if (fNamespace[i] == 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.util.Iterator | getPrefixes()
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 IteratorPrefixes(fPrefixes, count);
|
public java.util.Vector | getPrefixes(java.lang.String uri)
int count = 0;
String prefix = null;
boolean unique = true;
Vector prefixList = new Vector();
for (int i = fNamespaceSize; i >0 ; i -= 2) {
if(fNamespace[i-1] == uri){
if(!prefixList.contains(fNamespace[i-2]))
prefixList.add(fNamespace[i-2]);
}
}
return prefixList;
|
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--];
//System.out.println("Calling popContext, fCurrentContext = " + 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;
//System.out.println("calling push context, current context = " + fCurrentContext);
|
public void | reset()
// reset namespace and context info
fNamespaceSize = 0;
fCurrentContext = 0;
// 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;
fContext[fCurrentContext] = fNamespaceSize;
//++fCurrentContext;
|