Class ReadOnlyNamespaceRegistry
- java.lang.Object
-
- org.apache.jackrabbit.oak.plugins.name.ReadOnlyNamespaceRegistry
-
- All Implemented Interfaces:
NamespaceRegistry
,NamespaceConstants
- Direct Known Subclasses:
ReadWriteNamespaceRegistry
public class ReadOnlyNamespaceRegistry extends java.lang.Object implements NamespaceRegistry, NamespaceConstants
Read-only namespace registry. Used mostly internally when access to the in-content registered namespaces is needed. See theReadWriteNamespaceRegistry
subclass for a more complete registry implementation that supports also namespace modifications and that's thus better suited for use in in implementing the full JCR API.
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.oak.spi.namespace.NamespaceConstants
NAMESPACE_OAK, NAMESPACE_REP, NAMESPACE_SV, NAMESPACE_XMLNS, NAMESPACES_PATH, PREFIX_OAK, PREFIX_REP, PREFIX_SV, PREFIX_XMLNS, REP_NAMESPACES, REP_NSDATA, REP_PREFIXES, REP_URIS, RESERVED_PREFIXES, RESERVED_URIS
-
Fields inherited from interface javax.jcr.NamespaceRegistry
NAMESPACE_EMPTY, NAMESPACE_JCR, NAMESPACE_MIX, NAMESPACE_NT, NAMESPACE_XML, PREFIX_EMPTY, PREFIX_JCR, PREFIX_MIX, PREFIX_NT, PREFIX_XML
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyNamespaceRegistry(Root root)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull java.lang.String
getPrefix(java.lang.String uri)
Returns the prefix which is mapped to the givenuri
.@NotNull java.lang.String[]
getPrefixes()
Returns an array holding all currently registered prefixes.@NotNull java.lang.String
getURI(java.lang.String prefix)
Returns the URI to which the givenprefix
is mapped.@NotNull java.lang.String[]
getURIs()
Returns an array holding all currently registered URIs.void
registerNamespace(java.lang.String prefix, java.lang.String uri)
Sets a one-to-one mapping betweenprefix
anduri
in the global namespace registry of this repository.void
unregisterNamespace(java.lang.String prefix)
Removes a namespace mapping from the registry.
-
-
-
Constructor Detail
-
ReadOnlyNamespaceRegistry
public ReadOnlyNamespaceRegistry(Root root)
-
-
Method Detail
-
registerNamespace
public void registerNamespace(java.lang.String prefix, java.lang.String uri) throws RepositoryException
Description copied from interface:NamespaceRegistry
Sets a one-to-one mapping betweenprefix
anduri
in 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
.- Specified by:
registerNamespace
in interfaceNamespaceRegistry
- 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
public void unregisterNamespace(java.lang.String prefix) throws RepositoryException
Description copied from interface:NamespaceRegistry
Removes a namespace mapping from the registry.- Specified by:
unregisterNamespace
in interfaceNamespaceRegistry
- 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
@NotNull public @NotNull java.lang.String[] getPrefixes()
Description copied from interface:NamespaceRegistry
Returns an array holding all currently registered prefixes.- Specified by:
getPrefixes
in interfaceNamespaceRegistry
- Returns:
- a string array.
-
getURIs
@NotNull public @NotNull java.lang.String[] getURIs()
Description copied from interface:NamespaceRegistry
Returns an array holding all currently registered URIs.- Specified by:
getURIs
in interfaceNamespaceRegistry
- Returns:
- a string array.
-
getURI
@NotNull public @NotNull java.lang.String getURI(java.lang.String prefix) throws NamespaceException
Description copied from interface:NamespaceRegistry
Returns the URI to which the givenprefix
is mapped.- Specified by:
getURI
in interfaceNamespaceRegistry
- Parameters:
prefix
- a string.- Returns:
- a string.
- Throws:
NamespaceException
- if a mapping with the specifiedprefix
does not exist.
-
getPrefix
@NotNull public @NotNull java.lang.String getPrefix(java.lang.String uri) throws NamespaceException
Description copied from interface:NamespaceRegistry
Returns the prefix which is mapped to the givenuri
.- Specified by:
getPrefix
in interfaceNamespaceRegistry
- Parameters:
uri
- a string.- Returns:
- a string.
- Throws:
NamespaceException
- if a mapping with the specifieduri
does not exist.
-
-