Skip to content

Commit 651c99a

Browse files
committed
clarify javadoc of NamespaceResolver.getPrefix() to make it clear that
this is supposed to resolve the empty prefix as well In addition clarify that returning null is not allowed.
1 parent 46a2e50 commit 651c99a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/conversion/NameParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class NameParser {
4444
* @param jcrName the name to be parsed. The jcrName may either be in the
4545
* qualified or in the expanded form.
4646
* @param resolver <code>NamespaceResolver</code> use to retrieve the
47-
* namespace URI from the prefix contained in the given JCR name.
47+
* namespace URI from the prefix contained in the given JCR name. Must resolve the empty prefix "" as well.
4848
* @return qName the new <code>Name</code>
4949
* @throws IllegalNameException If <code>jcrName</code> is not a valid
5050
* JCR-style name.

jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceResolver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import javax.jcr.NamespaceException;
2020

21+
import org.apache.jackrabbit.spi.commons.conversion.NameParser;
22+
2123
/**
2224
* Interface for resolving namespace URIs and prefixes. Unlike the JCR
2325
* {@link javax.jcr.NamespaceRegistry} interface, this interface contains
@@ -30,9 +32,10 @@ public interface NamespaceResolver {
3032

3133
/**
3234
* Returns the URI to which the given prefix is mapped.
35+
* For the empty prefix the default namespace uri should be returned as the {@link NameParser} relies on that.
3336
*
3437
* @param prefix namespace prefix
35-
* @return the namespace URI to which the given prefix is mapped.
38+
* @return the namespace URI to which the given prefix is mapped (never {@code null}).
3639
* @throws NamespaceException if the prefix is unknown.
3740
*/
3841
String getURI(String prefix) throws NamespaceException;
@@ -41,7 +44,7 @@ public interface NamespaceResolver {
4144
* Returns the prefix which is mapped to the given URI.
4245
*
4346
* @param uri namespace URI
44-
* @return the prefix mapped to the given URI.
47+
* @return the prefix mapped to the given URI (never {@code null}).
4548
* @throws NamespaceException if the URI is unknown.
4649
*/
4750
String getPrefix(String uri) throws NamespaceException;

0 commit comments

Comments
 (0)