Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.property.basic
Class GraphNamespaceRegistry

    java.lang.Object
      org.modeshape.graph.property.basic.GraphNamespaceRegistry

All Implemented Interfaces:
  NamespaceRegistry

    @NotThreadSafe
    public class GraphNamespaceRegistry

extends Object
implements NamespaceRegistry

A `NamespaceRegistry` implementation that stores the namespaces in a Graph as individual nodes for each namespace, under a parent supplied by the constructor.

Nested Class Summary

Nested classes/interfaces inherited from interface org.modeshape.graph.property.NamespaceRegistry
`NamespaceRegistry.Namespace`

Field Summary
`static Name` | `DEFAULT_GENERATED_PROPERTY_NAME`
`static Name` | `DEFAULT_URI_PROPERTY_NAME`
`static String` | `GENERATED_PREFIX`
`protected static Pattern` | `GENERATED_PREFIX_PATTERN`

Constructor Summary
`GraphNamespaceRegistry(Graph store, Path parentOfNamespaceNodes, Name uriPropertyName, Name generatedPropertyName, Property... additionalProperties)`

Method Summary
`protected Map<String,String>` | `doRegister(Map<String,String> newUrisByPrefix)`
`protected boolean` | `doUnregister(String uri)`
`protected String` | `generatePrefix(Set<String> existingGeneratedPrefixes)`
`String` | `getDefaultNamespaceUri()` Return the namespace URI that is currently mapped to the empty prefix, or null if there is no current default namespace.
`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.
`Path` | `getParentOfNamespaceNodes()`
`protected String` | `getPrefixFor(Path path)`
`protected String` | `getPrefixFor(String name, int counter)`
`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.
`protected void` | `initializeCacheFromStore(NamespaceRegistry cache)`
`protected boolean` | `isGeneratedPrefix(String prefix)`
`boolean` | `isRegisteredNamespaceUri(String namespaceUri)` Return whether there is a registered prefix for the supplied namespace URI.
`protected String` | `readPrefixFor(String namespaceUri, boolean generateIfMissing)`
`protected String` | `readUriFor(String prefix)`
`void` | `refresh()` Refresh the namespaces from the persistent store, and update the embedded cache.
`void` | `register(Iterable<NamespaceRegistry.Namespace> namespaces)`
`void` | `register(Map<String,String> namespaceUrisByPrefix)` Register a set of namespaces.
`String` | `register(String prefix, String namespaceUri)` Register a new namespace using the supplied prefix, returning the namespace URI previously registered under that prefix.
`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_URI_PROPERTY_NAME

    public static final Name DEFAULT_URI_PROPERTY_NAME

### DEFAULT_GENERATED_PROPERTY_NAME

    public static final Name DEFAULT_GENERATED_PROPERTY_NAME

### GENERATED_PREFIX

    public static final String GENERATED_PREFIX

See Also:
  Constant Field Values

### GENERATED_PREFIX_PATTERN

    protected static final Pattern GENERATED_PREFIX_PATTERN

Constructor Detail

### GraphNamespaceRegistry

    public GraphNamespaceRegistry(Graph store,
                                  Path parentOfNamespaceNodes,
                                  Name uriPropertyName,
                                  Name generatedPropertyName,
                                  Property... additionalProperties)

Method Detail

### getParentOfNamespaceNodes

    public Path getParentOfNamespaceNodes()

  Returns:
    parentOfNamespaceNodes

### getNamespaceForPrefix

    public String getNamespaceForPrefix(String prefix)

  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)

  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)

  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()

  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`
  See Also:
    `NamespaceRegistry.register(java.lang.Iterable)`

### register

    public void register(Map<String,String> namespaceUrisByPrefix)

  Register a set of namespaces.

  Parameters:
    `namespaceUrisByPrefix` - the map of new namespace URIs by their prefix

### register

    public String register(String prefix,
                           String namespaceUri)

  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)

  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
  See Also:
    `NamespaceRegistry.unregister(java.lang.String)`

### getRegisteredNamespaceUris

    public Set<String> getRegisteredNamespaceUris()

  Obtain the set of namespaces that are registered.

  Specified by:
    `getRegisteredNamespaceUris` in interface `NamespaceRegistry`
  Returns:
    the set of

### getNamespaces

    public Set<NamespaceRegistry.Namespace> getNamespaces()

  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
  See Also:
    `NamespaceRegistry.getNamespaces()`

### refresh

    public void refresh()

  Refresh the namespaces from the persistent store, and update the embedded cache. This operation is done atomically.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`
  See Also:
    `Object.toString()`

### initializeCacheFromStore

    protected void initializeCacheFromStore(NamespaceRegistry cache)

### readUriFor

    protected String readUriFor(String prefix)

### getPrefixFor

    protected String getPrefixFor(Path path)

### getPrefixFor

    protected String getPrefixFor(String name,
                                  int counter)

### isGeneratedPrefix

    protected boolean isGeneratedPrefix(String prefix)

### generatePrefix

    protected String generatePrefix(Set<String> existingGeneratedPrefixes)

### readPrefixFor

    protected String readPrefixFor(String namespaceUri,
                                   boolean generateIfMissing)

### doRegister

    protected Map<String,String> doRegister(Map<String,String> newUrisByPrefix)

### doUnregister

    protected boolean doUnregister(String uri)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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