org.springframework.batch.support
Class BinaryExceptionClassifier

java.lang.Object
  extended by org.springframework.batch.support.ExceptionClassifierSupport
      extended by org.springframework.batch.support.BinaryExceptionClassifier
All Implemented Interfaces:
ExceptionClassifier

public class BinaryExceptionClassifier
extends ExceptionClassifierSupport

A ExceptionClassifier that has only two classes of exception. Provides convenient methods for setting up and querying the classification with boolean return type.

Author:
Dave Syer

Field Summary
static String NON_DEFAULT
          The classifier result for a non-default exception.
 
Fields inherited from class org.springframework.batch.support.ExceptionClassifierSupport
DEFAULT
 
Constructor Summary
BinaryExceptionClassifier()
           
 
Method Summary
 Object classify(Throwable throwable)
          Returns either ExceptionClassifierSupport.DEFAULT or NON_DEFAULT depending on the type of the throwable.
 boolean isDefault(Throwable throwable)
          Convenience method to return boolean if the throwable is classified as default.
 void setExceptionClasses(Class[] exceptionClasses)
          Set the special exceptions.
 
Methods inherited from class org.springframework.batch.support.ExceptionClassifierSupport
getDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NON_DEFAULT

public static final String NON_DEFAULT
The classifier result for a non-default exception.

See Also:
Constant Field Values
Constructor Detail

BinaryExceptionClassifier

public BinaryExceptionClassifier()
Method Detail

setExceptionClasses

public final void setExceptionClasses(Class[] exceptionClasses)
Set the special exceptions. Any exception on the list, or subclasses thereof, will be classified as non-default.

Parameters:
exceptionClasses - defaults to Exception.

isDefault

public boolean isDefault(Throwable throwable)
Convenience method to return boolean if the throwable is classified as default.

Parameters:
throwable - the Throwable to classify
Returns:
true if it is default classified (i.e. not on the list provided in setExceptionClasses(Class[]).

classify

public Object classify(Throwable throwable)
Returns either ExceptionClassifierSupport.DEFAULT or NON_DEFAULT depending on the type of the throwable. If the type of the throwable or one of its ancestors is on the exception class list the classification is as NON_DEFAULT.

Specified by:
classify in interface ExceptionClassifier
Overrides:
classify in class ExceptionClassifierSupport
Parameters:
throwable - the input exception. Can be null.
Returns:
an object.
See Also:
setExceptionClasses(Class[]), ExceptionClassifierSupport.classify(Throwable)


Copyright © 2009 SpringSource. All Rights Reserved.