Keel 2.1RC2

org.keel.models.util
Class SequenceContext

java.lang.Object
  extended byorg.keel.models.util.SequenceContext
All Implemented Interfaces:
java.io.Serializable

public class SequenceContext
extends java.lang.Object
implements java.io.Serializable

A simple class an instance of which is stored in the "per user" context when a user is running a "sequence" type model. When a model returns a response with no inputs, control is transferred back to the sequence as of the appropriate sequence number.

Author:
Michael Nash, with small modifications from Phil Brown.
See Also:
Serialized Form

Field Summary
static java.lang.String CONTEXT_KEY
           
private  ModelResponse currentResponse
           
private  boolean mergeDefault
           
private  java.lang.String modelName
           
private  int seqStepNum
          seqStepNum is an int that indicates the current step in a sequence.
private  java.lang.String sequenceName
           
private  Configuration[] sequenceSteps
           
 
Constructor Summary
SequenceContext()
          Constructor for SequenceContext.
SequenceContext(java.lang.String theSequenceName, int newSeq)
           
SequenceContext(java.lang.String theSequenceName, int sequenceStep, Configuration[] children, ModelResponse res)
          Creates a new SequenceContext, using the passed in parameters to initialize itself.
 
Method Summary
private  java.lang.String findModelName(Configuration[] children, int sequenceStep)
          This method gets the correct child node based on the sequenceStep, and returns the "name" attribute fro mthat node.
 ModelResponse getCurrentResponse()
          Returns the currentResponse.
 int getFirstSequenceStep(java.lang.String modelName)
          This convenience method will return the first sequence step found for a given model name.
 boolean getMergeResponsesDefault()
          Returns the value last set by setMergeDefault(...).
 java.lang.String getModelName()
           
 int getSeq()
          Deprecated. - use getSeqStepNum instead
 int getSeqStepNum()
           
static SequenceContext getSequenceContext(Context context)
          Gets and returns the sequenceContext for the current sequence, using the context passed in to look up the current sequenceContext.
static SequenceContext getSequenceContext(ModelRequest req)
          Gets and returns the sequenceContext for the current sequence, using the ModelRequest req to look up the current sequenceContext from the Context.
 java.lang.String getSequenceModel()
          Deprecated. - use getSequenceName() instead
 java.lang.String getSequenceName()
          Returns the name of the sequence
 Configuration[] getSequenceSteps()
           
static ModelResponse mergeResponse(ModelResponse base, ModelResponse layer)
           
 void setCurrentResponse(ModelResponse newResponse)
          Sets the currentResponse.
 void setMergeResponsesDefault(boolean mergeDefault)
          This method sets the value that will be returned by a call to getMergeDefault()
 void setModelName(java.lang.String string)
           
 void setSeq(int seq)
          Deprecated. - use setSeqStepNum instead
 void setSeqStepNum(int i)
           
 void setSequenceModel(java.lang.String sequenceModel)
          Deprecated. - use setSequenceName instead
 void setSequenceName(java.lang.String string)
           
 void setSequenceSteps(Configuration[] configurations)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_KEY

public static final java.lang.String CONTEXT_KEY
See Also:
Constant Field Values

sequenceName

private java.lang.String sequenceName

modelName

private java.lang.String modelName

seqStepNum

private int seqStepNum
seqStepNum is an int that indicates the current step in a sequence. The first step in a sequence is always 1.


currentResponse

private transient ModelResponse currentResponse

sequenceSteps

private Configuration[] sequenceSteps

mergeDefault

private boolean mergeDefault
Constructor Detail

SequenceContext

public SequenceContext()
Constructor for SequenceContext.


SequenceContext

public SequenceContext(java.lang.String theSequenceName,
                       int newSeq)

SequenceContext

public SequenceContext(java.lang.String theSequenceName,
                       int sequenceStep,
                       Configuration[] children,
                       ModelResponse res)
Creates a new SequenceContext, using the passed in parameters to initialize itself.

Parameters:
theSequenceName -
sequenceStep - - one based int which indicates which is the "current" element in the sequence.
children - - An array of Configuration elements. Each element in the Configuration[] represents a step in the sequence.
res - - The current response object.
Method Detail

findModelName

private java.lang.String findModelName(Configuration[] children,
                                       int sequenceStep)
This method gets the correct child node based on the sequenceStep, and returns the "name" attribute fro mthat node.

Parameters:
children -
sequenceStep -
Returns:

getFirstSequenceStep

public int getFirstSequenceStep(java.lang.String modelName)
This convenience method will return the first sequence step found for a given model name. Keep in mind that the same model name can be found many times in the sequence. This method only finds the first one. If a match is not found, the method returns zero.

Parameters:
modelName -
Returns:

getSequenceContext

public static SequenceContext getSequenceContext(ModelRequest req)
                                          throws ModelException
Gets and returns the sequenceContext for the current sequence, using the ModelRequest req to look up the current sequenceContext from the Context. Returns null if there is no sequenceContext in the current context.

Parameters:
req -
Returns:
Throws:
ModelException

getSequenceContext

public static SequenceContext getSequenceContext(Context context)
                                          throws ModelException
Gets and returns the sequenceContext for the current sequence, using the context passed in to look up the current sequenceContext. Returns null if there is no sequenceContext in the context passed in or if the context passed in is null.

Parameters:
context -
Returns:
Throws:
ModelException

getSeq

public int getSeq()
Deprecated. - use getSeqStepNum instead

Returns an int indicating which is the current step in the the seqStepNum. This int is one based, meaning the the first step in a sequence is step number 1 (not step number zero).

Returns:
int

getSequenceName

public java.lang.String getSequenceName()
Returns the name of the sequence

Returns:
String

getSequenceModel

public java.lang.String getSequenceModel()
Deprecated. - use getSequenceName() instead

Returns the sequenceName.

Returns:
String

setSeq

public void setSeq(int seq)
Deprecated. - use setSeqStepNum instead

Sets the seqStepNum. The sequence is one-based meaning the the first step in a sequence is step number 1 (not step number zero).


setSequenceModel

public void setSequenceModel(java.lang.String sequenceModel)
Deprecated. - use setSequenceName instead

Sets the sequenceName.


getCurrentResponse

public ModelResponse getCurrentResponse()
Returns the currentResponse.

Returns:
Modelesponse

setCurrentResponse

public void setCurrentResponse(ModelResponse newResponse)
                        throws ModelException
Sets the currentResponse.

Throws:
ModelException

mergeResponse

public static ModelResponse mergeResponse(ModelResponse base,
                                          ModelResponse layer)
                                   throws ModelException
Throws:
ModelException

getSequenceSteps

public Configuration[] getSequenceSteps()
Returns:

setSequenceSteps

public void setSequenceSteps(Configuration[] configurations)
Parameters:
configurations -

getSeqStepNum

public int getSeqStepNum()
Returns:

setSeqStepNum

public void setSeqStepNum(int i)
Parameters:
i -

setSequenceName

public void setSequenceName(java.lang.String string)
Parameters:
string -

setMergeResponsesDefault

public void setMergeResponsesDefault(boolean mergeDefault)
This method sets the value that will be returned by a call to getMergeDefault()

Parameters:
mergeDefault -

getMergeResponsesDefault

public boolean getMergeResponsesDefault()
Returns the value last set by setMergeDefault(...).
If setMergeDefault wasn't called, then it returns the static final boolean value Sequence.defaultForMergeResponse

Returns:

getModelName

public java.lang.String getModelName()
Returns:

setModelName

public void setModelName(java.lang.String string)
Parameters:
string -

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.