All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class oplan.util.match.MatchCase

java.lang.Object
   |
   +----oplan.util.match.MatchCase

public abstract class MatchCase
extends Object
The root class for entries in MatchTables.

If you think of a MatchTable as analogous to a case statement, a MatchCase is analogous to a single case clause, with the MatchCase's ifSelected method containing the code that is executed in the body of that clause.

A MatchCase normally contains a pattern that can be examined by the MatchTable that contains the MatchCase. The MatchCase's tryMatch method normally implements a match against that pattern.

If the MatchCase is used as a MatchTable default, the pattern and the tryMatch method are ignored.

See Also:
MatchTable, MatchEnv

Variable Index

 o pattern
An object to match against.

Constructor Index

 o MatchCase()

Method Index

 o ifSelected(Object, Object)
ifSelected is called by the MatchTable when tryMatch returns a non-null result.
 o tryMatch(Object)
tryMatch attempts to match against the pattern, returning null if the match fails and some non-null object (such as a MatchEnv) if the match succeeds.

Variables

 o pattern
 public Object pattern
An object to match against.

Constructors

 o MatchCase
 public MatchCase()

Methods

 o tryMatch
 public abstract Object tryMatch(Object data)
tryMatch attempts to match against the pattern, returning null if the match fails and some non-null object (such as a MatchEnv) if the match succeeds.

 o ifSelected
 public Object ifSelected(Object data,
                          Object matchResult)
ifSelected is called by the MatchTable when tryMatch returns a non-null result. The object that was matched, and the non-null match result, are passed as arguments to ifSelected. The method provided here simply returns the same match result.


All Packages  Class Hierarchy  This Package  Previous  Next  Index