org.apache.jackrabbit.jcr2spi.name
Class LocalNamespaceMappings

java.lang.Object
  extended by org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver
      extended by org.apache.jackrabbit.jcr2spi.name.LocalNamespaceMappings
All Implemented Interfaces:
NamespaceListener, NamespaceResolver

public class LocalNamespaceMappings
extends AbstractNamespaceResolver
implements NamespaceListener

Manager for local session namespace mappings. This class is used by the SessionImpl class to implement the local namespace mapping functionality required by the JCR API.

This class holds a reference to the underlying global and persistent namespace registry (a NamespaceRegistryImpl instance) and keeps track of local namespace mappings added by the session.

The namespace resolution methods required by the NamespaceResolver are implemented by first looking up the local namespace mapping and then backing to the underlying namespace registry.


Constructor Summary
LocalNamespaceMappings(NamespaceRegistryImpl nsReg)
          Creates a local namespace manager with the given underlying namespace registry.
 
Method Summary
 void dispose()
          Disposes this LocalNamespaceMappings.
 Map getLocalNamespaceMappings()
           
 String getPrefix(String uri)
          Returns the prefix which is mapped to the given URI.
 String[] getPrefixes()
          Returns all prefixes currently mapped.
 String getURI(String prefix)
          Returns the URI to which the given prefix is mapped.
 void namespaceAdded(String prefix, String uri)
          Notifies the listeners that a new namespace uri has been added and mapped to prefix.
 void namespaceRemapped(String oldPrefix, String newPrefix, String uri)
          Notifies the listeners that an existing namespace uri has been re-mapped from oldPrefix to newPrefix.
 void namespaceRemoved(String uri)
          Notifies the listeners that the namespace with the given uri has been unregistered.
 void setNamespacePrefix(String prefix, String uri)
          Rename a persistently registered namespace URI to the new prefix.
 
Methods inherited from class org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver
addListener, notifyNamespaceAdded, notifyNamespaceRemapped, notifyNamespaceRemoved, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalNamespaceMappings

public LocalNamespaceMappings(NamespaceRegistryImpl nsReg)
Creates a local namespace manager with the given underlying namespace registry.

Parameters:
nsReg - namespace registry
Method Detail

setNamespacePrefix

public void setNamespacePrefix(String prefix,
                               String uri)
                        throws NamespaceException,
                               RepositoryException
Rename a persistently registered namespace URI to the new prefix.

Parameters:
prefix - namespace prefix
uri - namespace URI
Throws:
NamespaceException
RepositoryException

getPrefixes

public String[] getPrefixes()
                     throws RepositoryException
Returns all prefixes currently mapped.

Returns:
an array holding all currently mapped prefixes
Throws:
RepositoryException - if an error occurs

dispose

public void dispose()
Disposes this LocalNamespaceMappings.


getLocalNamespaceMappings

public Map getLocalNamespaceMappings()
Returns:
the namespace mappings that are locally re-mapped.

getURI

public String getURI(String prefix)
              throws NamespaceException
Returns the URI to which the given prefix is mapped.

Specified by:
getURI in interface NamespaceResolver
Parameters:
prefix - namespace prefix
Returns:
the namespace URI to which the given prefix is mapped.
Throws:
NamespaceException - if the prefix is unknown.

getPrefix

public String getPrefix(String uri)
                 throws NamespaceException
Returns the prefix which is mapped to the given URI.

Specified by:
getPrefix in interface NamespaceResolver
Parameters:
uri - namespace URI
Returns:
the prefix mapped to the given URI.
Throws:
NamespaceException - if the URI is unknown.

namespaceAdded

public void namespaceAdded(String prefix,
                           String uri)
Description copied from interface: NamespaceListener
Notifies the listeners that a new namespace uri has been added and mapped to prefix.

Specified by:
namespaceAdded in interface NamespaceListener
Parameters:
prefix - the prefix.
uri - the namespace uri.

namespaceRemapped

public void namespaceRemapped(String oldPrefix,
                              String newPrefix,
                              String uri)
Description copied from interface: NamespaceListener
Notifies the listeners that an existing namespace uri has been re-mapped from oldPrefix to newPrefix.

Specified by:
namespaceRemapped in interface NamespaceListener
Parameters:
oldPrefix - the old prefix.
newPrefix - the new prefix.
uri - the associated namespace uri.

namespaceRemoved

public void namespaceRemoved(String uri)
Description copied from interface: NamespaceListener
Notifies the listeners that the namespace with the given uri has been unregistered.

Specified by:
namespaceRemoved in interface NamespaceListener
Parameters:
uri - the namespace uri.


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.