com.lonniepryor.blues.util
Class Throwables

java.lang.Object
  |
  +--com.lonniepryor.blues.util.Throwables

public abstract class Throwables
extends java.lang.Object

Specification interface for identifying sets of Types. Instances of this class may be logically combined using the AND, OR, and NOT operations. Many common use-cases are supplied via static accessor methods.

Version:
$Revision: 1.1 $
Author:
Lonnie Pryor

Constructor Summary
protected Throwables()
          Creates a new Throwables object.
 
Method Summary
 Throwables and(Throwables specification)
          Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right.
static Throwables any()
          Returns a specification matching any not-null throwable set.
static Throwables containing(Types specification)
          Returns a specification matching any throwable set containing an element that satisfies the supplied specification.
protected abstract  boolean evaluate(java.lang.Class[] throwableTypes)
          Returns true if the supplied throwable set satisfies this specification.
 boolean isSatisfiedBy(java.lang.Class[] throwableTypes)
          Returns true if the supplied throwable set is not null and satisfies this specification.
 boolean isSatisifiedByAll(java.lang.Class[][] all)
          Returns true if all of the supplied throwable sets satisfy this specification.
 boolean isSatisifiedByAny(java.lang.Class[][] any)
          Returns true if any of the supplied throwable sets satisfy this specification.
 Throwables not()
          Returns a specification representing a logical NOT of this specification.
 Throwables or(Throwables specification)
          Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right.
static Throwables parse(java.lang.String throwablesPattern)
          Parses a pattern string into a complete Throwables specification.
 java.lang.Class[][] selectAll(java.lang.Class[][] from)
          Selects all the throwable sets that satisfy this specification from the supplied array.
 java.lang.Class[] selectFirst(java.lang.Class[][] from)
          Selects the first throwable set that satisfies this specification from the supplied array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Throwables

protected Throwables()
Creates a new Throwables object.

Method Detail

any

public static Throwables any()
Returns a specification matching any not-null throwable set.

Returns:
A specification matching any not-null throwable set.

containing

public static Throwables containing(Types specification)
Returns a specification matching any throwable set containing an element that satisfies the supplied specification.

Parameters:
specification - The specification that any element in canidate throwable sets must match.
Returns:
A specification matching any throwable set containing an element that satisfies the supplied specification.

parse

public static Throwables parse(java.lang.String throwablesPattern)
Parses a pattern string into a complete Throwables specification. Format:
   throwables  ::=  element [ "," element ]...
   element     ::=  [ "!" ] ( types | ( "("  types-expr ")" ) )
 

Parameters:
throwablesPattern - The content of the pattern.
Returns:
A Throwables specification from the supplied pattern.
Throws:
ParseException - if the pattern is invalid.

isSatisfiedBy

public final boolean isSatisfiedBy(java.lang.Class[] throwableTypes)
Returns true if the supplied throwable set is not null and satisfies this specification.

Parameters:
throwableTypes - The throwable set to test.
Returns:
True if the supplied throwable set is not null and satisfies this specification.

evaluate

protected abstract boolean evaluate(java.lang.Class[] throwableTypes)
Returns true if the supplied throwable set satisfies this specification.

Parameters:
throwableTypes - The throwable set to test.
Returns:
True if the supplied throwable set satisfies this specification.

isSatisifiedByAll

public final boolean isSatisifiedByAll(java.lang.Class[][] all)
Returns true if all of the supplied throwable sets satisfy this specification.

Parameters:
all - The array of throwable sets to test.
Returns:
True if all of the supplied throwable sets satisfy this specification.

isSatisifiedByAny

public final boolean isSatisifiedByAny(java.lang.Class[][] any)
Returns true if any of the supplied throwable sets satisfy this specification.

Parameters:
any - The array of throwable sets to test.
Returns:
True if any of the supplied throwable sets satisfy this specification.

selectFirst

public final java.lang.Class[] selectFirst(java.lang.Class[][] from)
Selects the first throwable set that satisfies this specification from the supplied array.

Parameters:
from - The array of throwable sets to select from.
Returns:
The first throwable set that satisfies this specification from the supplied array.

selectAll

public final java.lang.Class[][] selectAll(java.lang.Class[][] from)
Selects all the throwable sets that satisfy this specification from the supplied array.

Parameters:
from - The array of throwable sets to select from.
Returns:
All the throwable sets that satisfy this specification from the supplied array.

and

public final Throwables and(Throwables specification)
Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right.

Parameters:
specification - The specification to AND with.
Returns:
A specification representing a logical AND of this specification on the left and the supplied specification on the right.

or

public final Throwables or(Throwables specification)
Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right.

Parameters:
specification - The specification to OR with.
Returns:
A specification representing a logical OR of this specification on the left and the supplied specification on the right.

not

public final Throwables not()
Returns a specification representing a logical NOT of this specification.

Returns:
A specification representing a logical NOT of this specification.


Copyright © 2003 Blues Framework. All Rights Reserved.