Skip to content

Commit

Permalink
1.4: Merged revision 680135 (JCR-1644)
Browse files Browse the repository at this point in the history
  • Loading branch information
jukka committed Aug 4, 2008
1 parent 8cf7ac3 commit d75ad2a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/main/java/org/apache/jackrabbit/core/xml/NamespaceContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ public NamespaceContext getParent() {
* @throws NamespaceException if the prefix is not mapped
*/
public String getURI(String prefix) throws NamespaceException {
String uri = (String) prefixToURI.get(prefix);
if (uri != null) {
return uri;
} else if (parent != null) {
return parent.getURI(prefix);
} else {
throw new NamespaceException("Unknown prefix: " + prefix);
NamespaceContext current = this;
while (current != null) {
String uri = (String) current.prefixToURI.get(prefix);
if (uri != null) {
return uri;
}
current = current.parent;
}
throw new NamespaceException("Unknown prefix: " + prefix);
}

/**
Expand All @@ -108,13 +109,14 @@ public String getURI(String prefix) throws NamespaceException {
* @throws NamespaceException if the URI is not mapped
*/
public String getPrefix(String uri) throws NamespaceException {
String prefix = (String) uriToPrefix.get(uri);
if (prefix != null) {
return prefix;
} else if (parent != null) {
return parent.getPrefix(uri);
} else {
throw new NamespaceException("Unknown URI: " + uri);
NamespaceContext current = this;
while (current != null) {
String prefix = (String) current.uriToPrefix.get(uri);
if (prefix != null) {
return prefix;
}
current = current.parent;
}
throw new NamespaceException("Unknown URI: " + uri);
}
}

0 comments on commit d75ad2a

Please sign in to comment.