CharArray getPrefix(CharSequence uri, int count) { for (int i = count; --i >= 0; ) { CharArray prefix = _prefixes[i]; CharArray namespace = _namespaces[i]; if (namespace.equals(uri)) { // Find matching uri. // Checks that the prefix has not been overwriten after being set. boolean isPrefixOverwritten = false; for (int j = i + 1; j < count; j++) { if (prefix.equals(_prefixes[j])) { isPrefixOverwritten = true; break; } } if (!isPrefixOverwritten) return prefix; } } return null; // Not bound. }
// Implements NamespaceContext public CharArray getPrefix(CharSequence uri) { if (uri == null) throw new IllegalArgumentException("null namespace URI not allowed"); return _defaultNamespace.equals(uri) ? _defaultNsPrefix : getPrefix(uri, _namespacesCount[_nesting]); }