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
-
pattern
- An object to match against.
-
MatchCase()
-
-
ifSelected(Object, Object)
-
ifSelected is called by the MatchTable when tryMatch returns
a non-null result.
-
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.
pattern
public Object pattern
- An object to match against.
MatchCase
public MatchCase()
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.
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