jfun.parsec
Class Catch1<T>

java.lang.Object
  extended by jfun.parsec.Catch1<T>
All Implemented Interfaces:
java.io.Serializable, Catch<T>

public final class Catch1<T>
extends java.lang.Object
implements Catch<T>, java.io.Serializable

Catch1 implements Catch and recovers the exception only when the exception is the same object that it expects.

Author:
Ben Yu 2004-11-13
See Also:
Serialized Form

Constructor Summary
Catch1(T target)
          Create a Catch1 object.
 
Method Summary
 Parser<T> catchException(java.lang.Object v, java.lang.Object e)
          if e is the same as the target object that this Catch object is expecting, it recovers the parser and make v the current return value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Catch1

public Catch1(T target)
Create a Catch1 object.

Parameters:
target - the expected target exception object.
Method Detail

catchException

public Parser<T> catchException(java.lang.Object v,
                                java.lang.Object e)
if e is the same as the target object that this Catch object is expecting, it recovers the parser and make v the current return value.

Specified by:
catchException in interface Catch<T>
Parameters:
v - the return value of the exceptional parser.
e - the exception thrown.
Returns:
the new Parser object.
See Also:
Catch.catchException(java.lang.Object, java.lang.Object)