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 Object implements NamespaceRegistry, NamespaceConstants
Read-only namespace registry. Used mostly internally when access to the in-content registered namespaces is needed. See the ReadWriteNamespaceRegistry 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.
  • Constructor Details

    • ReadOnlyNamespaceRegistry

      public ReadOnlyNamespaceRegistry(Root root)
  • Method Details

    • registerNamespace

      public void registerNamespace(String prefix, String uri) throws RepositoryException
      Description copied from interface: NamespaceRegistry
      Sets a one-to-one mapping between prefix and uri 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 interface NamespaceRegistry
      Parameters:
      prefix - The prefix to be mapped.
      uri - The URI to be mapped.
      Throws:
      RepositoryException - if another error occurs.
    • unregisterNamespace

      public void unregisterNamespace(String prefix) throws RepositoryException
      Description copied from interface: NamespaceRegistry
      Removes a namespace mapping from the registry.
      Specified by:
      unregisterNamespace in interface NamespaceRegistry
      Parameters:
      prefix - The prefix of the mapping to be removed.
      Throws:
      RepositoryException - if another error occurs.
    • getPrefixes

      @NotNull public @NotNull String[] getPrefixes()
      Description copied from interface: NamespaceRegistry
      Returns an array holding all currently registered prefixes.
      Specified by:
      getPrefixes in interface NamespaceRegistry
      Returns:
      a string array.
    • getURIs

      @NotNull public @NotNull String[] getURIs()
      Description copied from interface: NamespaceRegistry
      Returns an array holding all currently registered URIs.
      Specified by:
      getURIs in interface NamespaceRegistry
      Returns:
      a string array.
    • getURI

      @NotNull public @NotNull String getURI(String prefix) throws NamespaceException
      Description copied from interface: NamespaceRegistry
      Returns the URI to which the given prefix is mapped.
      Specified by:
      getURI in interface NamespaceRegistry
      Parameters:
      prefix - a string.
      Returns:
      a string.
      Throws:
      NamespaceException - if a mapping with the specified prefix does not exist.
    • getPrefix

      @NotNull public @NotNull String getPrefix(String uri) throws NamespaceException
      Description copied from interface: NamespaceRegistry
      Returns the prefix which is mapped to the given uri.
      Specified by:
      getPrefix in interface NamespaceRegistry
      Parameters:
      uri - a string.
      Returns:
      a string.
      Throws:
      NamespaceException - if a mapping with the specified uri does not exist.