org.apache.jackrabbit.name
Class AbstractNamespaceResolver

java.lang.Object
  extended byorg.apache.jackrabbit.name.AbstractNamespaceResolver
All Implemented Interfaces:
NamespaceResolver
Direct Known Subclasses:
AdditionalNamespaceResolver, NamespaceMappings, NamespaceRegistryImpl, SessionNamespaceResolver

public abstract class AbstractNamespaceResolver
extends Object
implements NamespaceResolver

Provides default implementations for the methods:

Subclasses may overwrite those methods with more efficient implementations e.g. using caching. This class also adds optional support for NamespaceListeners. To enable listener support call the constructor with supportListeners set to true. The default constructor will not enable listener support and all listener related methods will throw an UnsupportedOperationException in that case.


Constructor Summary
AbstractNamespaceResolver()
          Creates a AbstractNamespaceResolver without listener support.
AbstractNamespaceResolver(boolean supportListeners)
          Creates a AbstractNamespaceResolver with listener support if supportListeners is set to true.
 
Method Summary
 void addListener(NamespaceListener listener)
          Registers listener to get notifications when namespace mappings change.
 String getJCRName(QName name)
          Returns the qualified name in the prefixed JCR name format.
 QName getQName(String name)
          Parses the given prefixed JCR name into a qualified name.
protected  void notifyPrefixRemapped(String prefix, String uri)
          Notifies listeners that a prefix has been remapped.
 void removeListener(NamespaceListener listener)
          Removes the listener from this NamespaceRegistery.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jackrabbit.name.NamespaceResolver
getPrefix, getURI
 

Constructor Detail

AbstractNamespaceResolver

public AbstractNamespaceResolver()
Creates a AbstractNamespaceResolver without listener support.


AbstractNamespaceResolver

public AbstractNamespaceResolver(boolean supportListeners)
Creates a AbstractNamespaceResolver with listener support if supportListeners is set to true.

Parameters:
supportListeners - if true listener are supported by this instance.
Method Detail

getQName

public QName getQName(String name)
               throws IllegalNameException,
                      UnknownPrefixException
Description copied from interface: NamespaceResolver
Parses the given prefixed JCR name into a qualified name.

Specified by:
getQName in interface NamespaceResolver
Parameters:
name - the raw name, potentially prefixed.
Returns:
the QName instance for the raw name.
Throws:
IllegalNameException - if the given name is not a valid JCR name
UnknownPrefixException - if the JCR name prefix does not resolve

getJCRName

public String getJCRName(QName name)
                  throws NoPrefixDeclaredException
Description copied from interface: NamespaceResolver
Returns the qualified name in the prefixed JCR name format.

Specified by:
getJCRName in interface NamespaceResolver
Returns:
name the qualified name
Throws:
NoPrefixDeclaredException - if the namespace can not be resolved

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.

notifyPrefixRemapped

protected void notifyPrefixRemapped(String prefix,
                                    String uri)
Notifies listeners that a prefix has been remapped.

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


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