public class FiniteStateMachine
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
FiniteStateMachine.TermParticlePair |
Constructor and Description |
---|
FiniteStateMachine(UserComplexType type,
boolean determinized)
Create a finite state machine
|
Modifier and Type | Method and Description |
---|---|
void |
allocateStateNumber(AutomatonState state)
Allocate a unique number to a state, and index the state from the FSM
|
static NonDeterminizedState |
compileParticle(SchemaCompiler compiler,
Particle particle,
NonDeterminizedState endState,
UserComplexType subjectType,
FiniteStateMachine machine)
Static method to translate a particle to a Finite State Automaton, returning
the start state of the FSA.
|
static FiniteStateMachine |
determinize(SchemaCompiler compiler,
FiniteStateMachine nfsa)
Determinize the finite state machine: that is, ensure that there are no ambiguous
transitions from this state.
|
void |
display(Logger err)
Display the finite state machine.
|
AutomatonState |
getInitialState()
Get the initial state of this finite state machine
|
int |
getNumberOfStates()
Determine the number of states in this finite state machine
|
Wildcard |
getOpenContentWildcard()
Get the open content wildcard, if any
|
AutomatonState |
getState(int number)
Get the state with a given unique state number
|
boolean |
isOpenContentInterleaved()
Ask whether the open content wildcard for this finite state machine (assuming there is one)
permits interleaved content (as opposed to suffixed content only)
|
void |
serialize(SchemaModelSerializer serializer)
Output a reppresentation of this finite state machine
|
void |
setInitialState(AutomatonState initialState)
Set the initial state of this finite state machine
|
void |
setOpenContentWildcard(Wildcard wildcard,
boolean interleaved)
Set the open content wildcard for this machine
|
static java.lang.String |
subsumesMachine(FiniteStateMachine base,
FiniteStateMachine sub,
SchemaCompiler compiler)
Test whether one finite state machine subsumes another FSM: that is, whether for each path through
the second FSM, there is a corresponding path through the first FSM.
|
public FiniteStateMachine(UserComplexType type, boolean determinized)
type
- the type whose content model is implemented by this finite state machinedeterminized
- true if this machine is determinizedpublic void allocateStateNumber(AutomatonState state)
state
- the state whose number is to be allocatedpublic int getNumberOfStates()
public AutomatonState getInitialState()
public void setInitialState(AutomatonState initialState)
initialState
- the initial statepublic AutomatonState getState(int number)
number
- the number of the statepublic void setOpenContentWildcard(Wildcard wildcard, boolean interleaved)
wildcard
- the open content wildcard (may be null)interleaved
- true if open content may be interleaved, false if it must be suffixedpublic static NonDeterminizedState compileParticle(SchemaCompiler compiler, Particle particle, NonDeterminizedState endState, UserComplexType subjectType, FiniteStateMachine machine) throws SchemaException, MissingComponentException
compiler
- user for error reportingparticle
- the particle to be compiled, which is either an ElementDeclaration,
a WildCard, a choice, or a sequenceendState
- the State representing the final state of the automatonsubjectType
- the complex type to which this particle belongsmachine
- the finite state machine to which the state belongsSchemaException
- if XSD constraints are violatedMissingComponentException
- if unresolved references in the schema are foundpublic void display(Logger err)
err
- the output destinationpublic static java.lang.String subsumesMachine(FiniteStateMachine base, FiniteStateMachine sub, SchemaCompiler compiler)
base
- the first FSM (representing the base type)sub
- the other FSM (representing the type that is derived by restriction, validly or otherwise)compiler
- used for error reportingpublic static FiniteStateMachine determinize(SchemaCompiler compiler, FiniteStateMachine nfsa) throws SchemaException
compiler
- the schema compilernfsa
- the finite state machine to be determinizedSchemaException
- if an XSD constraint is violatedpublic Wildcard getOpenContentWildcard()
public boolean isOpenContentInterleaved()
public void serialize(SchemaModelSerializer serializer) throws XPathException
serializer
- the schema model serializer to which this representation is to be writtenXPathException
- if any error occurs during serializationCopyright (c) 2004-2018 Saxonica Limited. All rights reserved.