org.speakright.core
Class SRResults

java.lang.Object
  extended by org.speakright.core.SRResults
All Implemented Interfaces:
java.io.Serializable, IFlowContext

public class SRResults
extends java.lang.Object
implements IFlowContext, java.io.Serializable

Holds the results sent back by the VoiceXML platform. These are the results of executing the previous page, and include user input, errors, and events (like disconnect).

Author:
IanRaeLaptop
See Also:
Serialized Form

Nested Class Summary
static class SRResults.ResultCode
          Result code sent back by the VoiceXML platform, indicating the result of running the most recent VoiceXML page that we sent it.
 class SRResults.Slot
          Holds information about a single slot.
 
Field Summary
 boolean m_confirmationWasRejected
           
 java.lang.String m_input
           
 SRLocations m_locations
           
 int m_overallConfidence
           
 SRResults.ResultCode m_resultCode
           
 java.lang.String m_transferResult
           
 boolean m_validateSucceeded
           
 
Constructor Summary
SRResults()
           
SRResults(RawCGIParams params)
          Load from a set of CGI params (in a HTTP GET or POST).
SRResults(java.lang.String input)
           
SRResults(java.lang.String input, SRResults.ResultCode resultCode)
           
 
Method Summary
 void addSlot(java.lang.String slotName, java.lang.String value)
          Add a slot and its value.
 void addSlot(java.lang.String slotName, java.lang.String value, int confidence)
          Add a slot and its value.
 SRResults.Slot findSlot(java.lang.String slotName)
          The Slot object for the given slot
 SRResults.Slot getIthSlot(int index)
          Get the i-th slot in these results.
 SRLocations getLocations()
          get current resource file locations.
 java.lang.String getSlot(java.lang.String slotName)
          Get the value of the given slot.
 boolean hasSlot(java.lang.String slotName)
          Return true if the slot exists.
 void loadFrom(SRResults saved)
          Restore previous results.
 int slotCount()
          Get the number of slots in these results
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_input

public java.lang.String m_input

m_overallConfidence

public int m_overallConfidence

m_resultCode

public SRResults.ResultCode m_resultCode

m_transferResult

public java.lang.String m_transferResult

m_validateSucceeded

public boolean m_validateSucceeded

m_confirmationWasRejected

public boolean m_confirmationWasRejected

m_locations

public SRLocations m_locations
Constructor Detail

SRResults

public SRResults()

SRResults

public SRResults(java.lang.String input)

SRResults

public SRResults(java.lang.String input,
                 SRResults.ResultCode resultCode)

SRResults

public SRResults(RawCGIParams params)
Load from a set of CGI params (in a HTTP GET or POST). These include standard SpeakRight params such as sr__res, and VoiceXML field names (which map to SpeakRight slots) containing the user input.

Parameters:
params -
Method Detail

loadFrom

public void loadFrom(SRResults saved)
Restore previous results. Used in confirmation if user accepts (says 'yes') the confirmation. We need to restore the results that needed to be confirmed so that the next flow to execute sees them, not the 'yes' results.

Parameters:
saved - saved results from a previous execute

getLocations

public SRLocations getLocations()
Description copied from interface: IFlowContext
get current resource file locations.

Specified by:
getLocations in interface IFlowContext
Returns:
locations object

addSlot

public void addSlot(java.lang.String slotName,
                    java.lang.String value)
Add a slot and its value.

Parameters:
slotName - name of slot (used as field name in VoiceXML)
value - the value of the slot, which is usually the user input value returned by the grammar.

addSlot

public void addSlot(java.lang.String slotName,
                    java.lang.String value,
                    int confidence)
Add a slot and its value.

Parameters:
slotName - name of slot (used as field name in VoiceXML)
value - the value of the slot, which is usually the user input value returned by the grammar.
confidence - confidence level (0..100) that the speech recognition engine returned for the utterance. Sometimes there is a single overall confidence level, and sometimes each slot is given a separate confidence level.

getSlot

public java.lang.String getSlot(java.lang.String slotName)
Get the value of the given slot.

Parameters:
slotName - slot name
Returns:
slot's value or "" if not found.

hasSlot

public boolean hasSlot(java.lang.String slotName)
Return true if the slot exists.

Parameters:
slotName - slot name
Returns:

findSlot

public SRResults.Slot findSlot(java.lang.String slotName)
The Slot object for the given slot

Parameters:
slotName -
Returns:
Slot object, or null if not found

getIthSlot

public SRResults.Slot getIthSlot(int index)
Get the i-th slot in these results.

Parameters:
index - between 0 and slotCount() - 1 inclusive
Returns:
Slot object, or null if out of range

slotCount

public int slotCount()
Get the number of slots in these results

Returns:
number of slots (can be 0)