org.waveprotocol.wave.model.document.operation.NindoAutomaton
A state machine that can be used to accept or generate valid or invalid document operations. The basic usage model is as follows: An automaton is parameterized by a document and a set of constraints based on an XML schema, and will accept/generate all valid operations for that document and those constraints. Every possible mutation component (such as "elementStart(...)") corresponds to a potential transition of the automaton. The checkXXX methods (such as checkElementStart(...)) determine whether a given transition exists and is valid, or whether it is invalid, or ill-formed. The doXXX methods will perform the transition. Ill-formed transitions must not be performed. Invalid transitions are permitted, but after performing an invalid transition, the validity of any further mutation components is not clearly specified. The checkFinish() method determines whether ending an operation is acceptable, or whether any opening components are missing the corresponding closing component. The checkXXX methods accept a ViolationsAccu object where they will record details about any violations. If a proposed transition is invalid for more than one reason, the checkXXX method may detect only one (or any subset) of the reasons and record only those violations. The ViolationsAccu parameter may also be null, in which case details about the violations will not be recorded. To validate an operation, the automaton needs to be driven according to the mutation components in that operation. DocumentOperationValidator does this. To generate a random operation, the automaton needs to be driven based on a random document mutation component generator. RandomDocumentMutationGenerator does this.
@author ohler@google.com (Christian Ohler)