org.speakright.core
Interface IModelBinder

All Known Implementing Classes:
ModelBinder

public interface IModelBinder

IModelBinder binds user input to values in the model. When a flow object executes it can add bindings for slots in the SML that the speech platform will return. If the speech platform returns user input, the bindings are used to assign the user input data to values(s) in the model.

For example, a flow might ask the user for a city name, and tell SpeakRight to bind the SML slot "city" to the model value City (that is, M.City()).

Author:
Ian Rae

Method Summary
 void addBinding(IFlow flow, java.lang.String slotName, java.lang.String modelVar)
          Bind the given slot to a model variable.
 void bind(IFlow current, SRResults results)
          Inspect the results and bind any model variables that are bound to slot values in the results.
 boolean failed(SRError parent)
          extracts any errors that the model binder logged.
 java.util.ArrayList getBindings()
          Gets list of BindingSpec objects.
 IModel getModel()
          Get the model object.
 java.lang.String getModelValue(java.lang.String methodName)
          Get the value of the given model variable.
 void injectModel(IFlow flow)
          Set the flow's model field.
 void setBindings(java.util.ArrayList bindingL)
          Sets list of BindingSpec objects.
 void setModel(IModel model)
          Set the model object.
 

Method Detail

injectModel

void injectModel(IFlow flow)
Set the flow's model field. It must be named "M" and be an IModel-derived class.

Parameters:
flow -

addBinding

void addBinding(IFlow flow,
                java.lang.String slotName,
                java.lang.String modelVar)
Bind the given slot to a model variable. The speech rec results of this slot will be stored in the model variable.

Parameters:
flow - Flow object that creates a Question with the given slot.
slotName - slot name.
modelVar - model variable (the name of a field, eg "city")

bind

void bind(IFlow current,
          SRResults results)
Inspect the results and bind any model variables that are bound to slot values in the results.

Parameters:
current - currently executing flow object.
results - speech rec results (from the voicexml platform).

getModel

IModel getModel()
Get the model object. Each instance of a SpeakRight application has a singleton model. This method is used for serialization.

Returns:
the model object.

setModel

void setModel(IModel model)
Set the model object. This method is used after restoring the SpeakRight persistent state from the previous HTTP request.

Parameters:
model - the application instance's model

getModelValue

java.lang.String getModelValue(java.lang.String methodName)
Get the value of the given model variable. Uses reflection to avoid type-dependency on the app-defined model class.

Parameters:
methodName - name of the model variable (eg. "city")
Returns:
model variable's value, as a string.

failed

boolean failed(SRError parent)
extracts any errors that the model binder logged.

Parameters:
parent - error object to copy error info into.
Returns:
true if any errors have occured.

getBindings

java.util.ArrayList getBindings()
Gets list of BindingSpec objects. This method is used for SR persistence across HTTP requests.

Returns:

setBindings

void setBindings(java.util.ArrayList bindingL)
Sets list of BindingSpec objects. This method is used for SR persistence across HTTP requests.