org.modeshape.jcr.value.basic

## Class SimpleNamespaceRegistry

- java.lang.Object
- - org.modeshape.jcr.value.basic.SimpleNamespaceRegistry

- All Implemented Interfaces:
    NamespaceRegistry
  Direct Known Subclasses:
    LocalNamespaceRegistry

      @NotThreadSafe
      public class SimpleNamespaceRegistry
      extends Object
      implements NamespaceRegistry

  A simple `NamespaceRegistry` implementation that is not thread-safe, but that provides all the basic functionality.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.modeshape.jcr.value.NamespaceRegistry

      `NamespaceRegistry.Holder, NamespaceRegistry.Namespace`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_NAMESPACE_URI`
    `static String` | `DEFAULT_PREFIX_NUMBER_FORMAT`
    `static String` | `DEFAULT_PREFIX_TEMPLATE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleNamespaceRegistry()`
    `SimpleNamespaceRegistry(String defaultNamespaceUri)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()`
    `protected String` | `generatePrefix()`
    `String` | `getDefaultNamespaceUri()` Return the namespace URI that is currently mapped to the empty prefix, or null if there is no current default namespace.
    `String` | `getGeneratedPrefixTemplate()`
    `String` | `getNamespaceForPrefix(String prefix)` Get the namespace URI for the supplied prefix.
    `Set<NamespaceRegistry.Namespace>` | `getNamespaces()` Obtain a snapshot of all of the `namespaces` registered at the time this method is called.
    `String` | `getPrefixForNamespaceUri(String namespaceUri, boolean generateIfMissing)` Return the prefix used for the supplied namespace URI.
    `Set<String>` | `getRegisteredNamespaceUris()` Obtain the set of namespaces that are registered.
    `boolean` | `isRegisteredNamespaceUri(String namespaceUri)` Return whether there is a registered prefix for the supplied namespace URI.
    `void` | `register(Iterable<NamespaceRegistry.Namespace> namespaces)`
    `String` | `register(String prefix, String namespaceUri)` Register a new namespace using the supplied prefix, returning the namespace URI previously registered under that prefix.
    `void` | `setGeneratedPrefixTemplate(String prefixTemplate)`
    `String` | `toString()`
    `boolean` | `unregister(String namespaceUri)` Unregister the namespace with the supplied URI.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_NAMESPACE_URI

          public static final String DEFAULT_NAMESPACE_URI

      See Also:
        Constant Field Values

    - #### DEFAULT_PREFIX_TEMPLATE

          public static final String DEFAULT_PREFIX_TEMPLATE

      See Also:
        Constant Field Values

    - #### DEFAULT_PREFIX_NUMBER_FORMAT

          public static final String DEFAULT_PREFIX_NUMBER_FORMAT

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SimpleNamespaceRegistry

          public SimpleNamespaceRegistry()

    - #### SimpleNamespaceRegistry

          public SimpleNamespaceRegistry(String defaultNamespaceUri)

      Parameters:
        `defaultNamespaceUri` - the namespace URI to use for the default prefix

  - ### Method Detail

    - #### clear

          public void clear()

    - #### getGeneratedPrefixTemplate

          public String getGeneratedPrefixTemplate()

      Returns:
        prefixTemplate

    - #### setGeneratedPrefixTemplate

          public void setGeneratedPrefixTemplate(String prefixTemplate)

      Parameters:
        `prefixTemplate` - Sets prefixTemplate to the specified value.

    - #### getNamespaceForPrefix

          public String getNamespaceForPrefix(String prefix)

      Description copied from interface: `NamespaceRegistry`
      Get the namespace URI for the supplied prefix.
      Specified by:
        `getNamespaceForPrefix` in interface `NamespaceRegistry`
      Parameters:
        `prefix` - the namespace prefix
      Returns:
        the namespace URI for the supplied prefix, or null if there is no namespace currently registered to use that prefix

    - #### getPrefixForNamespaceUri

          public String getPrefixForNamespaceUri(String namespaceUri,
                                        boolean generateIfMissing)

      Description copied from interface: `NamespaceRegistry`
      Return the prefix used for the supplied namespace URI.
      Specified by:
        `getPrefixForNamespaceUri` in interface `NamespaceRegistry`
      Parameters:
        `namespaceUri` - the namespace URI
        `generateIfMissing` - true if the namespace URI has not already been registered and the method should auto-register the namespace with a generated prefix, or false if the method should never auto-register the namespace
      Returns:
        the prefix currently being used for the namespace, or `null` if the namespace has not been registered and `generateIfMissing` is `false`
      See Also:
        `NamespaceRegistry.isRegisteredNamespaceUri(String)`

    - #### isRegisteredNamespaceUri

          public boolean isRegisteredNamespaceUri(String namespaceUri)

      Description copied from interface: `NamespaceRegistry`
      Return whether there is a registered prefix for the supplied namespace URI.
      Specified by:
        `isRegisteredNamespaceUri` in interface `NamespaceRegistry`
      Parameters:
        `namespaceUri` - the namespace URI
      Returns:
        true if the supplied namespace has been registered with a prefix, or false otherwise

    - #### getDefaultNamespaceUri

          public String getDefaultNamespaceUri()

      Description copied from interface: `NamespaceRegistry`
      Return the namespace URI that is currently mapped to the empty prefix, or null if there is no current default namespace.
      Specified by:
        `getDefaultNamespaceUri` in interface `NamespaceRegistry`
      Returns:
        the namespace URI that represents the default namespace, or null if there is no default namespace

    - #### register

          public void register(Iterable<NamespaceRegistry.Namespace> namespaces)

      Specified by:
        `register` in interface `NamespaceRegistry`

    - #### register

          public String register(String prefix,
                        String namespaceUri)

      Description copied from interface: `NamespaceRegistry`
      Register a new namespace using the supplied prefix, returning the namespace URI previously registered under that prefix.
      Specified by:
        `register` in interface `NamespaceRegistry`
      Parameters:
        `prefix` - the prefix for the namespace, or null if a namesapce prefix should be generated automatically
        `namespaceUri` - the namespace URI
      Returns:
        the namespace URI that was previously registered with the supplied prefix, or null if the prefix was not previously bound to a namespace URI

    - #### unregister

          public boolean unregister(String namespaceUri)

      Description copied from interface: `NamespaceRegistry`
      Unregister the namespace with the supplied URI.
      Specified by:
        `unregister` in interface `NamespaceRegistry`
      Parameters:
        `namespaceUri` - the namespace URI
      Returns:
        true if the namespace was removed, or false if the namespace was not registered

    - #### getRegisteredNamespaceUris

          public Set<String> getRegisteredNamespaceUris()

      Description copied from interface: `NamespaceRegistry`
      Obtain the set of namespaces that are registered.
      Specified by:
        `getRegisteredNamespaceUris` in interface `NamespaceRegistry`
      Returns:
        the set of

    - #### getNamespaces

          public Set<NamespaceRegistry.Namespace> getNamespaces()

      Description copied from interface: `NamespaceRegistry`
      Obtain a snapshot of all of the `namespaces` registered at the time this method is called. The resulting set is immutable, and will not reflect changes made to the registry.
      Specified by:
        `getNamespaces` in interface `NamespaceRegistry`
      Returns:
        an immutable set of `NamespaceRegistry.Namespace` objects reflecting a snapshot of the registry; never null

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### generatePrefix

          protected String generatePrefix()

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.