javax.jcr
Interface NamespaceRegistry


public interface NamespaceRegistry

NamespaceRegistry represents the global persistent namespace registry of the JCR Repository.

See Also:
Workspace.getNamespaceRegistry()

Method Summary
 java.lang.String getPrefix(java.lang.String uri)
          Returns the prefix to which the given URI is mapped
 java.lang.String[] getPrefixes()
          Returns an array holding all currently registered prefixes.
 java.lang.String getURI(java.lang.String prefix)
          Returns the URI to which the given prefix is mapped.
 java.lang.String[] getURIs()
          Returns an array holding all currently registered URIs.
 void registerNamespace(java.lang.String prefix, java.lang.String uri)
          Sets a one-to-one mapping between prefix and URI in the global namespace registry of this repository.
 void unregisterNamespace(java.lang.String prefix)
          Removes a namespace mapping from the registry.
 

Method Detail

registerNamespace

public void registerNamespace(java.lang.String prefix,
                              java.lang.String uri)
                       throws NamespaceException,
                              UnsupportedRepositoryOperationException,
                              AccessDeniedException,
                              RepositoryException
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:

In a level 1 implementation, this method always throws an UnsupportedRepositoryOperationException.

If the session associated with the Workspace object through which this registry was acquired does not have sufficient permissions to register the namespace an AccessDeniedException is thrown.

A RepositoryException is thrown if another error occurs.

Parameters:
prefix - The prefix to be mapped.
uri - The URI to be mapped.
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(java.lang.String prefix)
                         throws NamespaceException,
                                UnsupportedRepositoryOperationException,
                                AccessDeniedException,
                                RepositoryException
Removes a namespace mapping from the registry. The following restriction apply: In a level 1 implementation, this method always throws an UnsupportedRepositoryOperationException.

If the session associated with the Workspace object through which this registry was acquired does not have sufficient permissions to unregister the namespace an AccessDeniedException is thrown.

A RepositoryException is thrown if another error occurs.

Parameters:
prefix - The prefix of the mapping to be removed.
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 java.lang.String[] getPrefixes()
                               throws RepositoryException
Returns an array holding all currently registered prefixes.

Returns:
a string array
Throws:
RepositoryException - if an error occurs.

getURIs

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

Returns:
a string array
Throws:
RepositoryException - if an error occurs.

getURI

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

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

getPrefix

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

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


Copyright © 2004-2005 Day Software Management AG. All Rights Reserved.