public class FsmDescriptor extends Object
The current implementation is very simple, and requires some user setup.
Basically, we use Java's Pattern
and
Matcher
to verify a regular expression on demand.
The user must map state transitions' string names onto characters, and
specify a regex that describes the state machine. Using this technique, we
can only validate when we transition to an end state; we just check to see
if accumulated characters comprise an allowed regular expression.
In this simple implementation, the tokens and characters may represent states or transitions, depending on what is most convenient. In either case, we just check that a sequence of them matches the regular expression governing this state machine.
Constructor and Description |
---|
FsmDescriptor(Map<String,Character> tokenMap,
String fsmRegex,
String lastTransition)
Create a finite state machine descriptor.
|
Modifier and Type | Method and Description |
---|---|
FsmCursor |
createCursor()
Create a cursor for performing and validating transitions according to this
state machine.
|
public FsmDescriptor(Map<String,Character> tokenMap, String fsmRegex, String lastTransition)
tokenMap
- mapping of transitions/states to charactersfsmRegex
- the regular expression, defined using the characters from the tokenMaplastTransition
- the name of the final transition/statepublic FsmCursor createCursor()
Copyright © 1970 The Apache Software Foundation. All rights reserved.