Package javax.jcr
Interface NamespaceRegistry
- All Known Implementing Classes:
ReadOnlyNamespaceRegistry,ReadWriteNamespaceRegistry
public interface NamespaceRegistry
Each repository has a single, persistent namespace registry represented by
the
NamespaceRegistry object, accessed via Workspace.getNamespaceRegistry(). The namespace registry contains the default
prefixes of the registered namespaces. The namespace registry may contain
namespaces that are not used in repository content, and there may be
repository content with namespaces that are not included in the registry.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA constant for the predefined namespace mapped by default to the prefix "" (the empty prefix).static final StringA constant for the predefined namespace mapped by default to the prefix "jcr".static final StringA constant for the predefined namespace mapped by default to the prefix "mix".static final StringA constant for the predefined namespace mapped by default to the prefix "nt".static final StringA constant for the predefined namespace mapped by default to the prefix "xml".static final StringA constant for the predefined namespace prefix "" (the empty prefix).static final StringA constant for the predefined namespace prefix "jcr".static final StringA constant for the predefined namespace prefix "mix".static final StringA constant for the predefined namespace prefix "nt".static final StringA constant for the predefined namespace prefix "xml". -
Method Summary
Modifier and TypeMethodDescriptionReturns the prefix which is mapped to the givenuri.String[]Returns an array holding all currently registered prefixes.Returns the URI to which the givenprefixis mapped.String[]getURIs()Returns an array holding all currently registered URIs.voidregisterNamespace(String prefix, String uri) Sets a one-to-one mapping betweenprefixanduriin the global namespace registry of this repository.voidunregisterNamespace(String prefix) Removes a namespace mapping from the registry.
-
Field Details
-
PREFIX_JCR
A constant for the predefined namespace prefix "jcr".- See Also:
-
PREFIX_NT
A constant for the predefined namespace prefix "nt".- See Also:
-
PREFIX_MIX
A constant for the predefined namespace prefix "mix".- See Also:
-
PREFIX_XML
A constant for the predefined namespace prefix "xml".- See Also:
-
PREFIX_EMPTY
A constant for the predefined namespace prefix "" (the empty prefix).- See Also:
-
NAMESPACE_JCR
A constant for the predefined namespace mapped by default to the prefix "jcr".- See Also:
-
NAMESPACE_NT
A constant for the predefined namespace mapped by default to the prefix "nt".- See Also:
-
NAMESPACE_MIX
A constant for the predefined namespace mapped by default to the prefix "mix".- See Also:
-
NAMESPACE_XML
A constant for the predefined namespace mapped by default to the prefix "xml".- See Also:
-
NAMESPACE_EMPTY
A constant for the predefined namespace mapped by default to the prefix "" (the empty prefix).- See Also:
-
-
Method Details
-
registerNamespace
void registerNamespace(String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException Sets a one-to-one mapping betweenprefixanduriin the global namespace registry of this repository.Assigning a new prefix to a URI that already exists in the namespace registry erases the old prefix. In general this can almost always be done, though an implementation is free to prevent particular remappings by throwing a
NamespaceException.On the other hand, taking a prefix that is already assigned to a URI and re-assigning it to a new URI in effect unregisters that URI. Therefore, the same restrictions apply to this operation as to
NamespaceRegistry.unregisterNamespace.- Parameters:
prefix- The prefix to be mapped.uri- The URI to be mapped.- Throws:
NamespaceException- If an attempt is made to re-assign a built-in prefix to a new URI or, to register a namespace with a prefix that begins with the characters "xml" (in any combination of case) or, An attempt is made to perform a prefix re-assignment that is forbidden for implementation-specific reasons.UnsupportedRepositoryOperationException- if this repository does not support namespace registry changes.AccessDeniedException- if the current session does not have sufficent access to register the namespace.RepositoryException- if another error occurs.
-
unregisterNamespace
void unregisterNamespace(String prefix) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException Removes a namespace mapping from the registry.- Parameters:
prefix- The prefix of the mapping to be removed.- Throws:
NamespaceException- if an attempt is made to unregister a built-in namespace or a namespace that is not currently registered or a namespace whose unregsitration is forbidden for implementation-specific reasons.UnsupportedRepositoryOperationException- if this repository does not support namespace registry changes.AccessDeniedException- if the current session does not have sufficent access to unregister the namespace.RepositoryException- if another error occurs.
-
getPrefixes
Returns an array holding all currently registered prefixes.- Returns:
- a string array.
- Throws:
RepositoryException- if an error occurs.
-
getURIs
Returns an array holding all currently registered URIs.- Returns:
- a string array.
- Throws:
RepositoryException- if an error occurs.
-
getURI
Returns the URI to which the givenprefixis mapped.- Parameters:
prefix- a string.- Returns:
- a string.
- Throws:
NamespaceException- if a mapping with the specifiedprefixdoes not exist.RepositoryException- if another error occurs.
-
getPrefix
Returns the prefix which is mapped to the givenuri.- Parameters:
uri- a string.- Returns:
- a string.
- Throws:
NamespaceException- if a mapping with the specifieduridoes not exist.RepositoryException- if another error occurs.
-