|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.erights.e.elib.base.Ejector
Untamed: An Ejector implements a non-local exit construct that can return a value. It works with an EscapeExpr to cause an escape to take place. When used directly from java, a typical pattern is:
Ejector ejector = new Ejector(); //cause ejector to be appropriately accessible from the try //block try { //blah blah blah if (we need to exit) { ejector.run(result); } //blah blah blah } catch (Ejection ej) { Object result = ejector.result(ej); } finally { ejector.disable(); }
Field Summary | |
private Ejection |
myEjection
|
private boolean |
myIsEnabled
|
private String |
myName
|
private Object |
myResult
|
Constructor Summary | |
Ejector(String optName)
Enabled: |
Method Summary | |
void |
disable()
Enabled: To avoid confusion, one should always disable an Ejector in a finally block on the way out of its catching context. |
boolean |
isEnabled()
Enabled: |
boolean |
isMine(Throwable t)
Enabled: Broken out into a separate public test so Ejection catchers can easily test against several Ejectors. |
Object |
result(Throwable t)
Enabled: Having caught a possible Ejection, the catcher asks an Ejector for the result corresponding to that Ejection. |
void |
run()
Enabled: Non-local exit returning null. |
Object |
run(Object result)
Enabled: Non-local exit returning 'result'. |
String |
toString()
Suppressed: |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private final String myName
private boolean myIsEnabled
private Object myResult
private Ejection myEjection
Constructor Detail |
public Ejector(String optName)
optName
- Method Detail |
public boolean isEnabled()
public void disable()
public boolean isMine(Throwable t)
public Object result(Throwable t)
public void run()
Equivalent to 'run(null)'.
run
in interface Runnable
java.lang.Thread#run()
public Object run(Object result)
Would normally return void, but to minimize on Deflectors, and since we're not returning anything anyway, we implement OneArgFunc, and so must return Object.
run
in interface OneArgFunc
public String toString()
toString
in class Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |