org.springframework.classify
Class BinaryExceptionClassifier

java.lang.Object
  extended by org.springframework.classify.SubclassClassifier<Throwable,Boolean>
      extended by org.springframework.classify.BinaryExceptionClassifier
All Implemented Interfaces:
Classifier<Throwable,Boolean>

public class BinaryExceptionClassifier
extends SubclassClassifier<Throwable,Boolean>

A Classifier for exceptions that has only two classes (true and false). Classifies objects according to their inheritance relation with the supplied types. If the object to be classified is one of the provided types, or is a subclass of one of the types, then the non-default value is returned (usually true).

Author:
Dave Syer, Gary Russell
See Also:
SubclassClassifier

Constructor Summary
BinaryExceptionClassifier(boolean defaultValue)
          Create a binary exception classifier with the provided default value.
BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses)
          Create a binary exception classifier with the default value false and value mapping true for the provided classes and their subclasses.
BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses, boolean value)
          Create a binary exception classifier with the provided classes and their subclasses.
BinaryExceptionClassifier(Map<Class<? extends Throwable>,Boolean> typeMap)
          Create a binary exception classifier using the given classification map and a default classification of false.
BinaryExceptionClassifier(Map<Class<? extends Throwable>,Boolean> typeMap, boolean defaultValue)
          Create a binary exception classifier using the given classification map and a default classification of false.
 
Method Summary
 Boolean classify(Throwable classifiable)
          Return the value from the type map whose key is the class of the given Throwable, or its nearest ancestor if a subclass.
 void setTraverseCauses(boolean traverseCauses)
           
 
Methods inherited from class org.springframework.classify.SubclassClassifier
getClassified, getDefault, setDefaultValue, setTypeMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryExceptionClassifier

public BinaryExceptionClassifier(boolean defaultValue)
Create a binary exception classifier with the provided default value.

Parameters:
defaultValue - defaults to false

BinaryExceptionClassifier

public BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses,
                                 boolean value)
Create a binary exception classifier with the provided classes and their subclasses. The mapped value for these exceptions will be the one provided (which will be the opposite of the default).

Parameters:
value -

BinaryExceptionClassifier

public BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses)
Create a binary exception classifier with the default value false and value mapping true for the provided classes and their subclasses.


BinaryExceptionClassifier

public BinaryExceptionClassifier(Map<Class<? extends Throwable>,Boolean> typeMap)
Create a binary exception classifier using the given classification map and a default classification of false.

Parameters:
typeMap -

BinaryExceptionClassifier

public BinaryExceptionClassifier(Map<Class<? extends Throwable>,Boolean> typeMap,
                                 boolean defaultValue)
Create a binary exception classifier using the given classification map and a default classification of false.

Parameters:
typeMap -
Method Detail

setTraverseCauses

public void setTraverseCauses(boolean traverseCauses)

classify

public Boolean classify(Throwable classifiable)
Description copied from class: SubclassClassifier
Return the value from the type map whose key is the class of the given Throwable, or its nearest ancestor if a subclass.

Specified by:
classify in interface Classifier<Throwable,Boolean>
Overrides:
classify in class SubclassClassifier<Throwable,Boolean>
Parameters:
classifiable - the input object. Can be null.
Returns:
an object. Can be null, but implementations should declare if this is the case.


Copyright © 2013 SpringSource. All Rights Reserved.