de.fhg.igd.jhsm.util
Class HSMValidator

java.lang.Object
  extended byde.fhg.igd.jhsm.util.HSMValidator

public class HSMValidator
extends Object

A validator for hsm data structures. This implementation represents a very pragmatic approach to validation. The datastructure is not tested against a grammar, only some selected tests are run. The idea here is to protect the user of jhsm from the most common mistakes.

Version:
"$Id: HSMValidator.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Jan Haevecker

Constructor Summary
HSMValidator()
           
 
Method Summary
private  void findSubstates(Set states, State current)
          Adds states to a given set that can be reached from a given state via transitions.
private  Set getAllSubstates(CompositeState hsm)
          Returns a set of all possible states that can be active inside a given hsm.
protected  void testBorderCrossingTransitions(State state)
          Tests if a given state does have border crossing transitions.
protected  void testHSMComplete(CompositeState hsm)
          Tests if a given hsm knows all states that should be contained in it.
protected  void testInitialState(CompositeState hsm)
          Tests if a given hsm has exactly one initial state.
protected  void testTransition(Transition trans)
           
 boolean validate(CompositeState hsm)
          Traverses a given hsm data structure and runs some predefined tests on it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HSMValidator

public HSMValidator()
Method Detail

validate

public boolean validate(CompositeState hsm)
                 throws InvalidHSMException
Traverses a given hsm data structure and runs some predefined tests on it.

Parameters:
hsm - The hsm to be validated.
Returns:
true if the validation did succeed.
Throws:
InvalidHSMException - if the validation did fail.

testInitialState

protected void testInitialState(CompositeState hsm)
                         throws InvalidHSMException
Tests if a given hsm has exactly one initial state.

Parameters:
hsm - The hsm to be tested.
Throws:
InvalidHSMException - if the test did fail.

testBorderCrossingTransitions

protected void testBorderCrossingTransitions(State state)
                                      throws InvalidHSMException
Tests if a given state does have border crossing transitions.

Parameters:
state - The state to be tested.
Throws:
InvalidHSMException - if the test did fail.

testHSMComplete

protected void testHSMComplete(CompositeState hsm)
                        throws InvalidHSMException
Tests if a given hsm knows all states that should be contained in it.

Parameters:
hsm - The hsm to be tested.
Throws:
InvalidHSMException - if the test did fail.

getAllSubstates

private Set getAllSubstates(CompositeState hsm)
Returns a set of all possible states that can be active inside a given hsm. The list contains the states that can really be reached by transitions not just the states that have been registered.


findSubstates

private void findSubstates(Set states,
                           State current)
Adds states to a given set that can be reached from a given state via transitions.


testTransition

protected void testTransition(Transition trans)
                       throws InvalidHSMException
Throws:
InvalidHSMException


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.