*/
if (nsURI == null || nsURI.length() == 0) {
throw new IllegalArgumentException("Illegal to pass null/empty prefix as argument.");
}
if (nsURI.equals(XMLConstants.XML_NS_URI)) {
return new SingletonIterator(XMLConstants.XML_NS_PREFIX);
}
if (nsURI.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
return new SingletonIterator(XMLConstants.XMLNS_ATTRIBUTE);
}
String[] ns = _declarationData;
String first = null;
ArrayList<String> all = null;
main_loop:
for (int i = 1, len = ns.length; i < len; i += 2) {
String currNS = ns[i];
if (currNS == nsURI || currNS.equals(nsURI)) {
// Need to ensure no masking occurs...
String prefix = ns[i-1];
for (int j = i+1; j < len; j += 2) {
// Prefixes are interned, can do straight equality check
if (ns[j] == prefix) {
continue main_loop; // was masked, need to ignore
}
}
if (first == null) {
first = prefix;
} else {
if (all == null) {
all = new ArrayList<String>();
all.add(first);
}
all.add(prefix);
}
}
}
if (all != null) {
return all.iterator();
}
if (first != null) {
return new SingletonIterator(first);
}
return EmptyIterator.getInstance();
}