uk.ac.starlink.ttools.cone
Class ConeErrorPolicy

java.lang.Object
  extended by uk.ac.starlink.ttools.cone.ConeErrorPolicy

public abstract class ConeErrorPolicy
extends Object

Defines how errors are treated during a multiple cone search operation. An instance of this class should be applied to a ConeSearcher object prior to use in order to make it obey the instance's policy on reacting to errors in the cone searcher's ConeSearcher.performSearch(double, double, double) method.

Could one write a more general class which does this one's job using proxies?

Since:
24 Jan 2007
Author:
Mark Taylor

Field Summary
static ConeErrorPolicy ABORT
          An error during a cone search results in a failure of the task.
static ConeErrorPolicy IGNORE
          Errors during cone searches are treated as if the search had returned with no results.
static ConeErrorPolicy RETRY
          If an error occurs during a cone search it is retried until a non-error result is obtained.
 
Constructor Summary
protected ConeErrorPolicy(String name)
          Constructor.
 
Method Summary
static ConeErrorPolicy addAdvice(ConeErrorPolicy policy, String advice)
          Returns a new policy which behaves like a base one, but provides a supplied message in the IOException which is thrown if the search fails.
abstract  ConeSearcher adjustConeSearcher(ConeSearcher base)
          Apply this method to a basic cone searcher to obtain a new one which uses the error-handling policy defined by this policy object.
static ConeErrorPolicy createRetryPolicy(String name, int nTry)
          Constructs an error policy which will retry the search a fixed number of times.
 String toString()
          Returns this object's name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ABORT

public static final ConeErrorPolicy ABORT
An error during a cone search results in a failure of the task.


IGNORE

public static final ConeErrorPolicy IGNORE
Errors during cone searches are treated as if the search had returned with no results.


RETRY

public static final ConeErrorPolicy RETRY
If an error occurs during a cone search it is retried until a non-error result is obtained. Use with care.

Constructor Detail

ConeErrorPolicy

protected ConeErrorPolicy(String name)
Constructor.

Parameters:
name - policy name
Method Detail

toString

public String toString()
Returns this object's name.

Overrides:
toString in class Object

adjustConeSearcher

public abstract ConeSearcher adjustConeSearcher(ConeSearcher base)
Apply this method to a basic cone searcher to obtain a new one which uses the error-handling policy defined by this policy object.

Parameters:
base - base cone searcher
Returns:
cone searcher based on base with possibly modified error handling

createRetryPolicy

public static ConeErrorPolicy createRetryPolicy(String name,
                                                int nTry)
Constructs an error policy which will retry the search a fixed number of times.

Parameters:
name - policy name
nTry - maximum number of attempts; if <=0 will retry indefinitely
Returns:
new error policy

addAdvice

public static ConeErrorPolicy addAdvice(ConeErrorPolicy policy,
                                        String advice)
Returns a new policy which behaves like a base one, but provides a supplied message in the IOException which is thrown if the search fails.

Parameters:
policy - base policy
advice - message of exception on failure


Copyright © 2009 Central Laboratory of the Research Councils. All Rights Reserved.