org.tm4j.net
Class SimpleLocatorResolverManager

java.lang.Object
  extended byorg.tm4j.net.SimpleLocatorResolverManager
All Implemented Interfaces:
LocatorResolver, LocatorResolverManager

public class SimpleLocatorResolverManager
extends java.lang.Object
implements LocatorResolverManager

A "default" LocatorResolverManager. This implementation provides an in-memory registry of resolvers and registers a URILocatorResolver for the URI notation by default. Other notations may be registered after construction. The null string is not supported as a notation string. Notation strings are treated as case-insensitive and are folded to upper-case.

Since:
0.7.0
Author:
Kal Ahmed

Field Summary
protected  java.util.Map m_resolversByNotation
          A map representing the managed resolvers by notation.
 
Constructor Summary
SimpleLocatorResolverManager()
          Constructs a new instance of this class.
 
Method Summary
 LocatorResolver addResolver(java.lang.String notation, LocatorResolver resolver)
          Adds a resolver for the specified notation to this manager.
 LocatorResolver getResolver(java.lang.String notation)
          Returns the resolver for the specified notation.
 java.util.Map getResolverMap()
          Returns an unmodifiable Map of resolvers by the notation they resolve.
 void removeResolver(java.lang.String notation)
          Removes the resolver for the specified notation from the manager.
 java.io.InputStream resolve(Locator loc)
          Opens an input stream from the location specified by locator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_resolversByNotation

protected java.util.Map m_resolversByNotation
A map representing the managed resolvers by notation.

Constructor Detail

SimpleLocatorResolverManager

public SimpleLocatorResolverManager()
Constructs a new instance of this class. By default, the new instance contains a single LocatorResolver, which is a new instance of URILocatorResolver. This new resolver is registered to the notation "URI".

Method Detail

addResolver

public LocatorResolver addResolver(java.lang.String notation,
                                   LocatorResolver resolver)
Description copied from interface: LocatorResolverManager
Adds a resolver for the specified notation to this manager. A manager can manage only a single resolver for each notation.

Specified by:
addResolver in interface LocatorResolverManager
Parameters:
notation - the notation resolved by the resolver.
resolver - the resolver to be added.
Returns:
the previously registered resolver for notation or null if there is no previously registered resolver for the notation.

getResolver

public LocatorResolver getResolver(java.lang.String notation)
Description copied from interface: LocatorResolverManager
Returns the resolver for the specified notation.

Specified by:
getResolver in interface LocatorResolverManager
Parameters:
notation - the notation to locate the resolver for.
Returns:
The registered resolver for notation. Returns null if no resolver is registered for notation.

removeResolver

public void removeResolver(java.lang.String notation)
Description copied from interface: LocatorResolverManager
Removes the resolver for the specified notation from the manager. That resolver will be unregistered in the manager and locators with the specified notation will no longer be resolvable via the manager.

Specified by:
removeResolver in interface LocatorResolverManager
Parameters:
notation - The notation for which to remove the resolver.

getResolverMap

public java.util.Map getResolverMap()
Description copied from interface: LocatorResolverManager
Returns an unmodifiable Map of resolvers by the notation they resolve.

Specified by:
getResolverMap in interface LocatorResolverManager
Returns:
Unmodifiable Map. Map key is the notation string, map value is the resolver registered for that notation.

resolve

public java.io.InputStream resolve(Locator loc)
                            throws java.io.IOException,
                                   LocatorResolutionException
Description copied from interface: LocatorResolver
Opens an input stream from the location specified by locator.

Specified by:
resolve in interface LocatorResolver
Parameters:
loc - the locator for which an input stream is to be opened.
Throws:
LocatorResolutionException - if the locator could not be resolved correctly.
java.io.IOException - if an unexpected condition occurred while attempting to open the input stream.