org.tm4j.net
Class LocatorBase

java.lang.Object
  extended byorg.tm4j.net.LocatorBase
All Implemented Interfaces:
Locator, java.io.Serializable

public abstract class LocatorBase
extends java.lang.Object
implements Locator, java.io.Serializable

An abstract base class implementing the Locator interface.

Since:
0.6.0
Author:
Kal Ahmed
See Also:
Serialized Form

Field Summary
protected  java.lang.String m_address
          The address of the resource which this locator represents.
protected  LocatorFactory m_factory
          The locator factory associated with this locator.
protected  java.lang.String m_notation
          This locator's notation.
 
Constructor Summary
LocatorBase()
          Creates an empty, uninitialized locator.
LocatorBase(Locator loc)
          Creates a locator from the given template, copying the original locator's notation and address.
LocatorBase(LocatorFactory factory)
          Creates a new locator and associates it with the given factory.
LocatorBase(LocatorFactory factory, java.lang.String notation, java.lang.String address)
          Creates a complete, initialized locator.
 
Method Summary
 java.lang.String getAddress()
          Gets the address associated with the locator
 LocatorFactory getFactory()
          Returns the locator factory associated with this locator.
 java.lang.String getNotation()
          Gets the string defining the notation type of this locator
 void initialise(java.lang.String notation, java.lang.String address)
          Initializes the locator with the specified notation and address.
abstract  boolean isSupportedNotation(java.lang.String notation)
          Determines whether the locator implementation supports the specified notation.
abstract  java.lang.String normalizeAddress(java.lang.String address)
          Returns a normalized representation of the locator's address.
 void setFactory(LocatorFactory factory)
          Associates the locator with the given factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.tm4j.net.Locator
copy, equals, hashCode, resolveRelative, resolveRelative
 

Field Detail

m_notation

protected java.lang.String m_notation
This locator's notation.


m_address

protected java.lang.String m_address
The address of the resource which this locator represents.


m_factory

protected LocatorFactory m_factory
The locator factory associated with this locator.

Constructor Detail

LocatorBase

public LocatorBase()
Creates an empty, uninitialized locator.


LocatorBase

public LocatorBase(LocatorFactory factory,
                   java.lang.String notation,
                   java.lang.String address)
            throws InvalidNotationException,
                   MalformedLocatorException
Creates a complete, initialized locator. This constructor is commonly invoked by factory classes implementing LocatorFactory.

Parameters:
factory - the factory which creates the locator.
notation - the locator's notation.
address - the address of the resource which this locator represents.
Throws:
InvalidNotationException - if the locator implementation does not support the given notation.
MalformedLocatorException - if the address cannot be normalized.

LocatorBase

public LocatorBase(LocatorFactory factory)
Creates a new locator and associates it with the given factory. This constructor is commonly invoked by factory classes implementing LocatorFactory and leaves the locator uninitialized. The factory class should subsequently invoke initialise(String, String).

Parameters:
factory - the factory which creates the locator.

LocatorBase

public LocatorBase(Locator loc)
            throws InvalidNotationException,
                   MalformedLocatorException
Creates a locator from the given template, copying the original locator's notation and address. This constructor does not associate the locator with any factory class.

Parameters:
loc - the locator to be copied
Throws:
InvalidNotationException - if the locator implementation does not support the given notation.
MalformedLocatorException - if the address cannot be normalized.
Method Detail

setFactory

public void setFactory(LocatorFactory factory)
Description copied from interface: Locator
Associates the locator with the given factory. Applications should ensure that this method is not invoked directly, except by factory classes implementing LocatorFactory.

Specified by:
setFactory in interface Locator
Parameters:
factory - the factory to be associated with the locator.

getFactory

public LocatorFactory getFactory()
Description copied from interface: Locator
Returns the locator factory associated with this locator.

Specified by:
getFactory in interface Locator
Returns:
The locator factory that created this locator.

initialise

public void initialise(java.lang.String notation,
                       java.lang.String address)
                throws InvalidNotationException,
                       MalformedLocatorException
Description copied from interface: Locator
Initializes the locator with the specified notation and address. This method is commonly called by constructors.

Specified by:
initialise in interface Locator
Parameters:
notation - the notation to be used for this locator.
address - the address to be defined by this locator.
Throws:
MalformedLocatorException - if the implementation failed to parse the given address.
InvalidNotationException - if the implementation does not support the specified notation type.

getAddress

public java.lang.String getAddress()
Description copied from interface: Locator
Gets the address associated with the locator

Specified by:
getAddress in interface Locator
Returns:
The address associated with the locator.

getNotation

public java.lang.String getNotation()
Description copied from interface: Locator
Gets the string defining the notation type of this locator

Specified by:
getNotation in interface Locator
Returns:
The notation type of the locator.

isSupportedNotation

public abstract boolean isSupportedNotation(java.lang.String notation)
Determines whether the locator implementation supports the specified notation.

Parameters:
notation - the notation identifier to check for.
Returns:
true if notation represents a locator notation supported by the implementing class, false otherwise.

normalizeAddress

public abstract java.lang.String normalizeAddress(java.lang.String address)
                                           throws MalformedLocatorException
Returns a normalized representation of the locator's address.

Parameters:
address - a generic string address that the implementation should normalize in the context it sees fit.
Returns:
an address which the locator implementation, in its own context, considers "normalized".
Throws:
MalformedLocatorException