edu.ksu.cis.projects.bogor.module.state
Class DefaultStateFactory

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.module.event.AbstractEventProvider
      extended by edu.ksu.cis.projects.bogor.module.state.event.AbstractStateEventProvider
          extended by edu.ksu.cis.projects.bogor.module.state.DefaultStateFactory
All Implemented Interfaces:
ISelfDescribingModule, IEventProvider, IModule, IStateFactory, IStateEventProvider, Disposable

public class DefaultStateFactory
extends AbstractStateEventProvider
implements IStateFactory, ISelfDescribingModule

The default implementation of IStateFactory.

Version:
CVS $Revision: 1.19 $ $Date: 2005/02/23 16:33:30 $
Author:
Robby

Field Summary
protected  IBogorConfiguration bc
          Holds the Bogor configuration for this state factory.
protected  int nextThreadDesc
          Holds the next thread descriptor.
protected  SymbolTable st
           
protected  String[] stateAugmenterClassNames
          Java class names of the state space contributors.
protected  IStateAugmenter[] stateAugmenters
          State space contributors.
protected  IValueFactory valueFactory
          Holds the value factory for this state factory.
 
Fields inherited from class edu.ksu.cis.projects.bogor.module.state.event.AbstractStateEventProvider
dsenBackward, dsenForward
 
Fields inherited from class edu.ksu.cis.projects.bogor.module.event.AbstractEventProvider
isForward, s, threadId
 
Fields inherited from interface edu.ksu.cis.projects.bogor.module.IStateFactory
EPSILON_THREAD, STATE_AUGMENTER_ID
 
Constructor Summary
DefaultStateFactory()
           
 
Method Summary
 void augmentState(IState state, BitBuffer bb)
          Write extra components of state space into bitwise representation.
 IMessageStore connect(IBogorConfiguration bc)
          Connects this modules to other modules.
 IState createState(IStateFactoryArguments sfa)
          Creates an initial state.
 void dispose()
          Remove references.
 String getCopyrightNotice()
          Returns the copyright notice for this module.
 Pair<Domain,Boolean> getOptionDomain(String id)
           
 Collection<Triple<String,Boolean,OptionScope>> getOptionIds()
           
 IStateAugmenter[] getStateAugmenters()
          Get the set of state augmenters that contribute to the state space.
 Collection<String> getSuggestedValues(String id, IBogorConfiguration bc, SymbolTable st)
           
 int getThreadDescriptorSeed()
          Gets the thread descriptor seed.
 int newThreadDescriptor()
          Creates a fresh thread descriptor.
 IMessageStore setOptions(String key, Properties configuration)
          Sets the options for this module.
 void setThreadDescriptorSeed(int newSeed)
          Sets the thread descriptor seed.
 void validate(IState state)
          Validates a state.
 boolean validate(String id, String value, IBogorConfiguration bc, SymbolTable st, Collection<FileMessage> errors)
          Checks whether the value of a configuration option is legal.
 
Methods inherited from class edu.ksu.cis.projects.bogor.module.state.event.AbstractStateEventProvider
getNotifier, getNotifier
 
Methods inherited from class edu.ksu.cis.projects.bogor.module.event.AbstractEventProvider
backward, forward, getState, getThreadId, isBackward, isForward, removeContext, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.ksu.cis.projects.bogor.module.state.event.IStateEventProvider
getNotifier, getNotifier
 
Methods inherited from interface edu.ksu.cis.projects.bogor.module.event.IEventProvider
backward, forward, getState, getThreadId, isBackward, isForward, removeContext, setContext
 

Field Detail

st

protected SymbolTable st

valueFactory

protected IValueFactory valueFactory
Holds the value factory for this state factory. Non-null if connected.


bc

protected IBogorConfiguration bc
Holds the Bogor configuration for this state factory.


nextThreadDesc

protected int nextThreadDesc
Holds the next thread descriptor.


stateAugmenterClassNames

protected String[] stateAugmenterClassNames
Java class names of the state space contributors.


stateAugmenters

protected IStateAugmenter[] stateAugmenters
State space contributors. Used for things like maintaining current property automaton position.

Constructor Detail

DefaultStateFactory

public DefaultStateFactory()
Method Detail

getCopyrightNotice

public String getCopyrightNotice()
Description copied from interface: IModule
Returns the copyright notice for this module.

Specified by:
getCopyrightNotice in interface IModule
Returns:
The copyright notice for this module. Returns null if no additional notice is necessary.

setOptions

public IMessageStore setOptions(String key,
                                Properties configuration)
Description copied from interface: IModule
Sets the options for this module.

Specified by:
setOptions in interface IModule
Parameters:
key - The key (prefix) for this module options. Must be non-null. The key is used for module specific options.
configuration - The options for all modules. Must be non-null.

setThreadDescriptorSeed

public void setThreadDescriptorSeed(int newSeed)
Description copied from interface: IStateFactory
Sets the thread descriptor seed.

Specified by:
setThreadDescriptorSeed in interface IStateFactory
Parameters:
newSeed - The new thread descriptor.

getThreadDescriptorSeed

public int getThreadDescriptorSeed()
Description copied from interface: IStateFactory
Gets the thread descriptor seed.

Specified by:
getThreadDescriptorSeed in interface IStateFactory
Returns:
The thread descriptor seed.

connect

public IMessageStore connect(IBogorConfiguration bc)
Description copied from interface: IModule
Connects this modules to other modules.

Specified by:
connect in interface IModule
Parameters:
bc - The Bogor configuration containing modules to connect to. Must be non-null.

createState

public IState createState(IStateFactoryArguments sfa)
Description copied from interface: IStateFactory
Creates an initial state.

Specified by:
createState in interface IStateFactory
Returns:
The initial state that has one thread, which is the main thread. The main thread is runnable. The lock count of the main thread is zero.

dispose

public void dispose()
Description copied from interface: Disposable
Remove references. Once called, avoid using this object.

Specified by:
dispose in interface Disposable

newThreadDescriptor

public int newThreadDescriptor()
Description copied from interface: IStateFactory
Creates a fresh thread descriptor.

Specified by:
newThreadDescriptor in interface IStateFactory
Returns:
A unique thread descriptor.

validate

public void validate(IState state)
Description copied from interface: IStateFactory
Validates a state.

Specified by:
validate in interface IStateFactory
Parameters:
state - The state to be validated. Must be non-null.

getStateAugmenters

public IStateAugmenter[] getStateAugmenters()
Description copied from interface: IStateFactory
Get the set of state augmenters that contribute to the state space.

Specified by:
getStateAugmenters in interface IStateFactory

augmentState

public void augmentState(IState state,
                         BitBuffer bb)
Description copied from interface: IStateFactory
Write extra components of state space into bitwise representation.

Specified by:
augmentState in interface IStateFactory

getOptionIds

public Collection<Triple<String,Boolean,OptionScope>> getOptionIds()
Specified by:
getOptionIds in interface ISelfDescribingModule
Returns:
a set of tuples whose first element says the name of the option, and whose second element says whether the option is required, and whose third element says whether the option is private to this module (and thus prefixed by the interface implemented, e.g., edu.ksu.cis.projects.bogor.module.ISearcher) or global in scope (and thus no qualifier is prepended).

getOptionDomain

public Pair<Domain,Boolean> getOptionDomain(String id)
Specified by:
getOptionDomain in interface ISelfDescribingModule
Returns:
a tuple whose first element says the domain of the option values, and whose second element says whether the option is multivalued (that is, a comma-separated list)

getSuggestedValues

public Collection<String> getSuggestedValues(String id,
                                             IBogorConfiguration bc,
                                             SymbolTable st)
Specified by:
getSuggestedValues in interface ISelfDescribingModule

validate

public boolean validate(String id,
                        String value,
                        IBogorConfiguration bc,
                        SymbolTable st,
                        Collection<FileMessage> errors)
Checks whether the value of a configuration option is legal.

Specified by:
validate in interface ISelfDescribingModule
Parameters:
id - the option's name, as returned by the first tuple element of an item returned by getOptionIds()
value - the value of the option, or null if unconfigued
st - the symbol table for the BIR model
errors - a container into which errors should be put. Implementors should not assume that errors is empty upon entry into this method; it may aggregate the results of calling validate on many ISelfDescribingModule instances.
Returns:
true iff the option is supported and its value is legal