ConForM.CoopnTools.CoKer.ScenarioMgr
Class ScenarioMgr

java.lang.Object
  |
  +--ConForM.CoopnTools.CoKer.ScenarioMgr.ScenarioMgr

public class ScenarioMgr
extends java.lang.Object

Scenario Manager. This class essentially defines the services provided by the scenario manager.


Field Summary
static java.lang.String VERSION
          specification Manager version;
 
Constructor Summary
ScenarioMgr(CoopnSpec spec, CoopnEnv env)
          Constructor.
 
Method Summary
 Scenario createScenario(java.lang.String name)
          Creates and store an empty scenario.
 Scenario createSemantics()
          Creates and store an empty semantics.
 java.lang.String displayComment(java.lang.String elem)
          Comment to String conversion.
 java.lang.String displayModuleName(java.lang.String elem)
          ModuleName to String conversion.
 void dispose()
          Leave a package manager.
 java.lang.String evalComment(java.lang.String string)
          String to comment conversion.
 java.lang.String evalModuleName(java.lang.String string)
          String to ModuleName conversion.
 boolean exists(java.lang.String scenarioName)
          Look if a scenario already exists.
 Scenario getScenario(java.lang.String name)
          Load a scenario.
 Scenario getSemantics()
          Load the semantics of the specification.
 CoopnUser lockScenario(java.lang.String scenarioName, CoopnUser user)
          Lock a scenario.
 CoopnUser lockSemantics(CoopnUser user)
          Lock a semantics.
 java.lang.String semanticsName()
          Get the name of the scenario known as "the semantics".
 CoopnSpec specification()
          Get the associated spec.
 SpecMgr specMgr()
          Get the associated spec manager.
 void storeScenario(Scenario scenario)
          Store a scenario, or a semantics.
 void storeScenarioAs(Scenario scenario, java.lang.String name, CoopnUser user)
          Store a scenario under a particular name.
 void unlockScenario(java.lang.String scenarioName)
          Unlock a scenario.
 void unlockSemantics()
          Unlock a semantics.
 boolean upToDate(Scenario scenario)
          Look if a scenario is up-to-date with regards to the underlying specification.
 void use()
          Uses an aspect manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
specification Manager version;
Constructor Detail

ScenarioMgr

public ScenarioMgr(CoopnSpec spec,
                   CoopnEnv env)
            throws java.lang.IllegalArgumentException
Constructor. Build and use a new scenario manager.
Parameters:
spec - the associated specification
env - the environment of the scenario manager
Throws:
java.lang.IllegalArgumentException - the environment is absent or inconsistent.
Method Detail

use

public void use()
Uses an aspect manager.

dispose

public void dispose()
Leave a package manager. This method release the resources used by this manager, if it is not used any more.

semanticsName

public java.lang.String semanticsName()
Get the name of the scenario known as "the semantics".

lockSemantics

public CoopnUser lockSemantics(CoopnUser user)
Lock a semantics. Only one lock may exist on a semantics or scenario at the same time. Only locked semantics may be modified.
Parameters:
user - the user who want to acquire the lock
Returns:
null iff this operation succeeded, i.e. if the lock is granted; the user which already has the lock else.
Throws:
java.lang.IllegalArgumentException - an argument is illegal

lockScenario

public CoopnUser lockScenario(java.lang.String scenarioName,
                              CoopnUser user)
Lock a scenario. Only one lock may exist on a semantics or scenario at the same time. Only locked scenarios may be modified.
Parameters:
scenarioName - the scenario to lock
user - the user who want to acquire the lock
Returns:
null iff this operation succeeded, i.e. if the lock is granted; the user which already has the lock else.
Throws:
java.lang.IllegalArgumentException - an argument is illegal

unlockSemantics

public void unlockSemantics()
Unlock a semantics. If the semantics was locked, it is stored on disk (if needed). Else, nothing happens...

unlockScenario

public void unlockScenario(java.lang.String scenarioName)
Unlock a scenario. If the scenario was locked, it is stored on disk (if needed). Else, nothing happens...

specMgr

public SpecMgr specMgr()
Get the associated spec manager.

specification

public CoopnSpec specification()
Get the associated spec.

getSemantics

public Scenario getSemantics()
Load the semantics of the specification. The semantics of the specification is a particular scenario, the name of which is equal to the name of the specification.
Returns:
the scenario corresponding to the semantics of the spec, or null if the scenario does not exist yet.

getScenario

public Scenario getScenario(java.lang.String name)
Load a scenario.
Parameters:
name - the name of the scenario; a null value is used to load the semantics of the specification.
Returns:
the desired scenario, or null if this scenario does not exist yet.

createSemantics

public Scenario createSemantics()
                         throws java.lang.IllegalAccessException
Creates and store an empty semantics. The semantics must be locked by the user.

createScenario

public Scenario createScenario(java.lang.String name)
                        throws java.lang.IllegalAccessException
Creates and store an empty scenario. The scenario must be locked by the user.
Parameters:
name - the name of the scenario; a null value is used to load the semantics of the specification.
Returns:
the desired scenario.

upToDate

public boolean upToDate(Scenario scenario)
Look if a scenario is up-to-date with regards to the underlying specification.

exists

public boolean exists(java.lang.String scenarioName)
Look if a scenario already exists.

storeScenario

public void storeScenario(Scenario scenario)
                   throws java.lang.IllegalAccessException
Store a scenario, or a semantics. The scenario must be locked by the user.

storeScenarioAs

public void storeScenarioAs(Scenario scenario,
                            java.lang.String name,
                            CoopnUser user)
                     throws java.lang.IllegalAccessException
Store a scenario under a particular name. The scenario must be locked by the user. The lock is released, but a new lock is put for the new scenario.

evalComment

public java.lang.String evalComment(java.lang.String string)
                             throws java.lang.IllegalArgumentException
String to comment conversion. Evaluates a string into a valid scenario comment.
Parameters:
string - the string to evaluates; may be null
Returns:
the desired package comment.
Throws:
java.lang.IllegalArgumentException - the element cannot be delivered (because it is erroneous, and so on).

displayComment

public java.lang.String displayComment(java.lang.String elem)
                                throws java.lang.IllegalArgumentException
Comment to String conversion. Display a comment into a string representing it.
Parameters:
elem - the element to display; may be null
Returns:
the desired string.
Throws:
java.lang.IllegalArgumentException - the string cannot be delivered (because it is erroneous, and so on).

evalModuleName

public java.lang.String evalModuleName(java.lang.String string)
                                throws java.lang.IllegalArgumentException
String to ModuleName conversion. Evaluates a string into a valid scenario module name.
Parameters:
string - the string to evaluates
Returns:
the desired package module name as a String.
Throws:
java.lang.IllegalArgumentException - the element cannot be delivered (because it is erroneous, and so on).

displayModuleName

public java.lang.String displayModuleName(java.lang.String elem)
                                   throws java.lang.IllegalArgumentException
ModuleName to String conversion. Display a module name into a string representing it.
Parameters:
elem - the element to display
Returns:
the desired string.
Throws:
java.lang.IllegalArgumentException - the string cannot be delivered (because it is erroneous, and so on).