public interface DataModel
There is a single global data model that is created when the system is first initialized. Access to data is controlled by means of scopes, which are stored in a stack. Data is always accessed within a particular scope, which may be specified by name but defaults to being the top scope in the stack. At initialization time, a single scope named "Global" is created. Thereafter scopes are explicitly created and destroyed by the data model's clients.
Some first steps to follow the ideas mentioned in the VoiceXML 3.0 draft http://www.w3.org/ TR/voicexml30/#Resources:Datamodel
| Modifier and Type | Field and Description |
|---|---|
static int |
ERROR_SCOPE_NOT_FOUND
A specified scope could not be found.
|
static int |
ERROR_VARIABLE_ALREADY_DEFINED
A specified variable was previously defined.
|
static int |
ERROR_VARIABLE_NOT_FOUND
A specified variable was not found.
|
| Modifier and Type | Method and Description |
|---|---|
int |
createArray(java.lang.String arrayName,
int dimension)
Creates an array with the given dimension on top most scope on the scope
stack.
|
int |
createArray(java.lang.String arrayName,
int dimension,
Scope scope)
Creates an array with the given dimension at the specified scope.
|
java.lang.Object |
createNewObject()
Retrieves a new empty object for this data model.
|
int |
createScope()
Creates a new scope object and pushes it on top of the scope stack.
|
int |
createScope(Scope scope)
Creates a new scope object and pushes it on top of the scope stack.
|
int |
createVariable(java.lang.String variableName)
Creates a variable with the default value specified by the underlying
datamodel retrieved via
getUndefinedValue() at the topmost scope
on the scope stack. |
int |
createVariable(java.lang.String variableName,
java.lang.Object value)
Creates a variable with the given initial value on top most scope on the
scope stack.
|
int |
createVariable(java.lang.String variableName,
java.lang.Object value,
Scope scope)
Creates a variable.
|
int |
createVariableFor(java.lang.Object variable,
java.lang.String variableName)
Creates a variable as a nested property in the specified variable
container with the default value specified by the underlying datamodel
retrieved via
getUndefinedValue() at the topmost scope on the
scope stack. |
int |
createVariableFor(java.lang.Object variable,
java.lang.String variableName,
java.lang.Object value)
Creates a variable as a nested property in the given container with the
given initial value on top most scope on the scope stack.
|
int |
deleteScope()
Removes a topmost scope from the scope stack.
|
int |
deleteScope(Scope scope)
Removes a scope with the provided name from the scope stack.
|
int |
deleteVariable(java.lang.String variableName)
Deletes the variable with the specified name from the topmost scope on
the stack.
|
int |
deleteVariable(java.lang.String variableName,
Scope scope)
Deletes the variable with the specified name from the specified scope..
|
<T> T |
evaluateExpression(java.lang.String expr,
java.lang.Class<T> type)
Evaluates the specified expression in the topmost scope on the stack and
returns it value.
|
<T> T |
evaluateExpression(java.lang.String expr,
Scope scope,
java.lang.Class<T> type)
Evaluates the specified expression in the specified scope and returns it
value.
|
boolean |
existsVariable(java.lang.String variableName)
Checks if the given variable exists.
|
boolean |
existsVariable(java.lang.String variableName,
Scope scope)
Checks if the given variable exists at the given scope.
|
DataModelObjectSerializer |
getSerializer()
Retrieves the Serializer for objects when submitting.
|
java.lang.Object |
getUndefinedValue()
Retrieves the value for undefined.
|
DataModel |
newInstance()
Creates a new data model.
|
<T> T |
readArray(java.lang.String arrayName,
int position,
java.lang.Class<T> type)
Returns the value of the array at the given position with the specified
name from the topmost scope on the stack.
|
<T> T |
readArray(java.lang.String arrayName,
int position,
Scope scope,
java.lang.Class<T> type)
Returns the value of the array at the given position with the specified
name from the specified scope on the stack.
|
<T> T |
readVariable(java.lang.String variableName,
java.lang.Class<T> type)
Returns the value of the variable with the specified name from the
topmost scope on the stack.
|
<T> T |
readVariable(java.lang.String variableName,
Scope scope,
java.lang.Class<T> type)
Returns the value of the variable with the specified name from the
specified scope on the stack.
|
int |
resizeArray(java.lang.String arrayName,
int dimension)
Resizes an array with the given dimension on top most scope on the scope
stack.
|
int |
resizeArray(java.lang.String arrayName,
int dimension,
Scope scope)
Resizes an array with the given dimension at the specified scope.
|
java.lang.String |
toString(java.lang.Object object)
Retrieves a human readable representation of the given object retrieved
from this data model.
|
int |
updateArray(java.lang.String variableName,
int position,
java.lang.Object newValue)
Assigns a new value to the array at the given position on the topmost
scope on the stack.
|
int |
updateArray(java.lang.String variableName,
int position,
java.lang.Object newValue,
Scope scope)
Assigns a new value to the array at the given position in the specified
scope.
|
int |
updateVariable(java.lang.String variableName,
java.lang.Object newValue)
Assigns a new value to the variable specified on the topmost scope on the
stack.
|
int |
updateVariable(java.lang.String variableName,
java.lang.Object newValue,
Scope scope)
Assigns a new value to the variable specified from the specified scope.
|
int |
updateVariableFor(java.lang.Object variable,
java.lang.String variableName,
java.lang.Object newValue)
Assigns a new value to the variable specified on the topmost scope on the
stack.
|
static final int ERROR_SCOPE_NOT_FOUND
static final int ERROR_VARIABLE_NOT_FOUND
static final int ERROR_VARIABLE_ALREADY_DEFINED
DataModel newInstance()
java.lang.Object getUndefinedValue()
null may
be returned to indicate a defined variable with no value.java.lang.Object createNewObject()
java.lang.String toString(java.lang.Object object)
object - the value to convertobjectint createScope(Scope scope)
scope - the scope to create0 upon success, failure status if a scope already exists
with the specified name.int createScope()
0 upon successint deleteScope()
0 upon successint deleteScope(Scope scope)
scope - the scope to remove0 upon success, failure status if the stack is empty or
no scope with the specified name existsint createVariable(java.lang.String variableName)
getUndefinedValue() at the topmost scope
on the scope stack.variableName - name of the variable to create0 upon success, failure status if a variable of the same
name already existsint createVariableFor(java.lang.Object variable,
java.lang.String variableName)
getUndefinedValue() at the topmost scope on the
scope stack.variable - the container (previously obtained from the datamodel) where
to create the variablevariableName - name of the variable to create0 upon success, failure status if a variable of the same
name already existsint createVariable(java.lang.String variableName,
java.lang.Object value)
variableName - name of the variable to createvalue - initial value of the variable0 upon success, failure status if a variable of the same
name already existsint createVariableFor(java.lang.Object variable,
java.lang.String variableName,
java.lang.Object value)
variable - the container (previously obtained from the datamodel) where
to create the variablevariableName - name of the variable to createvalue - initial value of the variable0 upon success, failure status if a variable of the same
name already existsint createVariable(java.lang.String variableName,
java.lang.Object value,
Scope scope)
getUndefinedValue().variableName - name of the variable to createvalue - initial value of the variable, maybe nullscope - scope, where to create the variable0 upon success, failure status if a variable of the same
name already exists in the specified scopeint createArray(java.lang.String arrayName,
int dimension)
arrayName - name of the array to createdimension - initial dimension of the array0 upon success, failure status if a variable of the same
name already existsint createArray(java.lang.String arrayName,
int dimension,
Scope scope)
arrayName - name of the array to createdimension - initial dimension of the arrayscope - scope, where to create the array0 upon success, failure status if a variable of the same
name already exists in the specified scopeint resizeArray(java.lang.String arrayName,
int dimension)
arrayName - name of the array to createdimension - new dimension of the array after resizing0 upon success, failure status if the array could not be
foundint resizeArray(java.lang.String arrayName,
int dimension,
Scope scope)
arrayName - name of the array to createdimension - new dimension of the array after resizingscope - scope, where to create the variable0 upon success, failure status if the array could not be
foundboolean existsVariable(java.lang.String variableName)
variableName - name of the variable to checktrue if the variable existsboolean existsVariable(java.lang.String variableName,
Scope scope)
variableName - name of the variable to checkscope - the scope where to check for the variabletrue if the variable existsint deleteVariable(java.lang.String variableName)
variableName - the variable to delete0 upon success, failure status if no variable with the
specified name existsint deleteVariable(java.lang.String variableName,
Scope scope)
variableName - the variable to deletescope - scope, where to delete the variable0 upon success, failure status if no variable with the
specified name existsint updateVariable(java.lang.String variableName,
java.lang.Object newValue)
variableName - the variable to updatenewValue - new value of the variable0 upon success, failure status if the specified variable
or scope cannot be found.int updateVariableFor(java.lang.Object variable,
java.lang.String variableName,
java.lang.Object newValue)
variable - the variable that has variableName as a propertyvariableName - the variable to updatenewValue - new value of the variable0 upon success, failure status if the specified variable
or scope cannot be found.int updateVariable(java.lang.String variableName,
java.lang.Object newValue,
Scope scope)
variableName - the variable to updatenewValue - new value of the variablescope - scope, where to update the variable0 upon success, failure status if no variable with the
specified name existsint updateArray(java.lang.String variableName,
int position,
java.lang.Object newValue)
variableName - the variable to updateposition - the position in the array to updatenewValue - new value of the variable0 upon success, failure status if the specified variable,
field, or scope cannot be found.int updateArray(java.lang.String variableName,
int position,
java.lang.Object newValue,
Scope scope)
variableName - the variable to updateposition - the position in the array to updatenewValue - new value of the variablescope - scope, where to update the variable0 upon success, failure status if no variable with the
specified name exists<T> T readVariable(java.lang.String variableName,
java.lang.Class<T> type)
throws SemanticError
T - type of the variable to readvariableName - the variable to deletetype - type of the variableSemanticError - if the specified variable or scope can not be found<T> T readVariable(java.lang.String variableName,
Scope scope,
java.lang.Class<T> type)
throws SemanticError
T - type of the variable to readvariableName - the variable to deletescope - scope, where to update the variabletype - type of the variableSemanticError - if the specified variable or scope can not be found<T> T readArray(java.lang.String arrayName,
int position,
java.lang.Class<T> type)
throws SemanticError
T - type of the variable to readarrayName - the variable to deleteposition - the position to read fromtype - type of the variableSemanticError - if the specified variable or scope can not be found<T> T readArray(java.lang.String arrayName,
int position,
Scope scope,
java.lang.Class<T> type)
throws SemanticError
T - type of the variable to readarrayName - the variable to deleteposition - the position to read fromscope - scope, where to update the variabletype - type of the variableSemanticError - if the specified variable or scope can not be found<T> T evaluateExpression(java.lang.String expr,
java.lang.Class<T> type)
throws SemanticError
T - type of the variable to readexpr - the expression to evaluatetype - type of the variableSemanticError - if the specified scope can not be found or the expression
could not be evaluated<T> T evaluateExpression(java.lang.String expr,
Scope scope,
java.lang.Class<T> type)
throws SemanticError
T - type of the variable to readexpr - the expression to evaluatescope - scope, where to evaluate the expressiontype - type of the variableSemanticError - if the specified scope can not be found or the expression
could not be evaluatedDataModelObjectSerializer getSerializer()