org.apache.jackrabbit.jcr2spi.name
Class NamespaceCache

java.lang.Object
  extended by org.apache.jackrabbit.jcr2spi.name.NamespaceCache

public class NamespaceCache
extends Object

NamespaceCache...


Method Summary
 void addListener(NamespaceListener listener)
          Registers listener to get notifications when namespace mappings change.
static NamespaceCache getInstance(RepositoryService service)
          Returns the NamespaceCache for the given RepositoryService.
 String getPrefix(NamespaceStorage storage, String uri)
          Returns the prefix to which the given URI is mapped
 String[] getPrefixes(NamespaceStorage storage)
          Returns an array holding all currently registered prefixes.
 String getURI(NamespaceStorage storage, String prefix)
          Returns the URI to which the given prefix is mapped.
 String[] getURIs(NamespaceStorage storage)
          Returns an array holding all currently registered URIs.
protected  void notifyNamespaceAdded(String prefix, String uri)
          Notifies the listeners that a new namespace uri has been added and mapped to prefix.
protected  void notifyNamespaceRemapped(String oldPrefix, String newPrefix, String uri)
          Notifies listeners that an existing namespace uri has been remapped to a new prefix.
protected  void notifyNamespaceRemoved(String uri)
          Notifies the listeners that the namespace with the given uri has been removed from the mapping.
 void registerNamespace(NamespaceStorage storage, String prefix, String uri)
          Registers a new name space.
 void removeListener(NamespaceListener listener)
          Removes the listener from this NamespaceRegistery.
 void unregisterNamespace(NamespaceStorage storage, String prefix)
          Unregisters a namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static NamespaceCache getInstance(RepositoryService service)
                                  throws RepositoryException
Returns the NamespaceCache for the given RepositoryService.

Parameters:
service - the repository service.
Returns:
the NamespaceCache for the repository service.
Throws:
RepositoryException - if an error occurs while reading from the service.

registerNamespace

public void registerNamespace(NamespaceStorage storage,
                              String prefix,
                              String uri)
                       throws NamespaceException,
                              UnsupportedRepositoryOperationException,
                              AccessDeniedException,
                              RepositoryException
Registers a new name space.

Parameters:
storage - the underlying namespace storage.
prefix - the namespace prefix.
uri - the namespace URI.
Throws:
NamespaceException - if an illegal attempt is made to register a mapping.
UnsupportedRepositoryOperationException - in a level 1 implementation
AccessDeniedException - if the session associated with the Workspace object through which this registry was acquired does not have sufficient permissions to register the namespace.
RepositoryException - if another error occurs.

unregisterNamespace

public void unregisterNamespace(NamespaceStorage storage,
                                String prefix)
                         throws NamespaceException,
                                UnsupportedRepositoryOperationException,
                                AccessDeniedException,
                                RepositoryException
Unregisters a namespace.

Parameters:
storage - the namespace storage.
prefix - the prefix for the namespace to remove.
Throws:
NamespaceException - if an illegal attempt is made to remove a mapping.
UnsupportedRepositoryOperationException - in a level 1 implementation
AccessDeniedException - if the session associated with the Workspace object through which this registry was acquired does not have sufficient permissions to unregister the namespace.
RepositoryException - if another error occurs.

getPrefixes

public String[] getPrefixes(NamespaceStorage storage)
                     throws RepositoryException
Returns an array holding all currently registered prefixes.

Parameters:
storage - the namespace storage
Returns:
a string array
Throws:
RepositoryException - if an error occurs.

getURIs

public String[] getURIs(NamespaceStorage storage)
                 throws RepositoryException
Returns an array holding all currently registered URIs.

Parameters:
storage - the namespace storage
Returns:
a string array
Throws:
RepositoryException - if an error occurs.

getURI

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

Parameters:
storage - the namespace storage.
prefix - a string
Returns:
the namespace URI for the prefix.
Throws:
NamespaceException - if the prefix is unknown.
RepositoryException - is another error occurs

getPrefix

public String getPrefix(NamespaceStorage storage,
                        String uri)
                 throws NamespaceException,
                        RepositoryException
Returns the prefix to which the given URI is mapped

Parameters:
storage - the namespace storage.
uri - a string
Returns:
the namespace prefix for the uri.
Throws:
NamespaceException - if the URI is unknown.
RepositoryException - is another error occurs

addListener

public void addListener(NamespaceListener listener)
Registers listener to get notifications when namespace mappings change.

Parameters:
listener - the listener to register.
Throws:
UnsupportedOperationException - if listener support is not enabled for this AbstractNamespaceResolver.

removeListener

public void removeListener(NamespaceListener listener)
Removes the listener from this NamespaceRegistery.

Parameters:
listener - the listener to remove.
Throws:
UnsupportedOperationException - if listener support is not enabled for this AbstractNamespaceResolver.

notifyNamespaceAdded

protected void notifyNamespaceAdded(String prefix,
                                    String uri)
Notifies the listeners that a new namespace uri has been added and mapped to prefix.

Parameters:
prefix - the prefix.
uri - the namespace uri.

notifyNamespaceRemapped

protected void notifyNamespaceRemapped(String oldPrefix,
                                       String newPrefix,
                                       String uri)
Notifies listeners that an existing namespace uri has been remapped to a new prefix.

Parameters:
oldPrefix - the old prefix.
newPrefix - the new prefix.
uri - the associated namespace uri.

notifyNamespaceRemoved

protected void notifyNamespaceRemoved(String uri)
Notifies the listeners that the namespace with the given uri has been removed from the mapping.

Parameters:
uri - the namespace uri.
See Also:
NamespaceListener.namespaceRemoved(String)


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