mobi.voiceassistant.base
Class Scope

java.lang.Object
  extended by mobi.voiceassistant.base.Scope

public final class Scope
extends Object

Scope is a mapping of some ResId which denotes module to some ComponentName which denotes Agent. It also contains some specification how Response and further requests should be handled.

See Also:
Response.enterScope(Scope), PendingInput

Field Summary
static int MODE_FOREIGN
          Input in foreign scopes handled in specified locale instead of assistant's default.
static int MODE_MODAL
          Modal scopes match instead of root ones.
static int MODE_QUESTION
          Question scope means that more input from user is expected.
 
Constructor Summary
Scope(ComponentName component, ResId module, int mode)
           
Scope(ComponentName component, ResId module, int mode, Locale locale)
           
 
Method Summary
 ComponentName getComponent()
          Returns component for this scope passed to constructor.
 Locale getLocale()
          Returns locale for this scope passed to Scope(ComponentName, ResId, int, Locale).
 int getMode()
          Returns mode for this scope passed to constructor.
 ResId getModuleResource()
          Returns module id for this scope passed to constructor.
static Scope readFromParcel(Parcel parcel)
           
static void writeToParcel(Scope scope, Parcel parcel, int flags)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_MODAL

public static final int MODE_MODAL
Modal scopes match instead of root ones.

See Also:
Scope(ComponentName, ResId, int), Scope(ComponentName, ResId, int, Locale), getMode(), Constant Field Values

MODE_FOREIGN

public static final int MODE_FOREIGN
Input in foreign scopes handled in specified locale instead of assistant's default. Should always be used with MODE_MODAL

See Also:
Scope(ComponentName, ResId, int, Locale), getLocale(), getMode(), Constant Field Values

MODE_QUESTION

public static final int MODE_QUESTION
Question scope means that more input from user is expected. Suggestion for assistant to turn microphone on after response displayed and/or utterance complete.

See Also:
Scope(ComponentName, ResId, int), Scope(ComponentName, ResId, int, Locale), getMode(), Constant Field Values
Constructor Detail

Scope

public Scope(ComponentName component,
             ResId module,
             int mode)
Parameters:
component - Component pair of mapping
module - Module pair of mapping
mode - Scope's mode
Throws:
IllegalArgumentException - if mode contains MODE_FOREIGN
See Also:
Scope(ComponentName, ResId, int, Locale), MODE_MODAL, MODE_FOREIGN, MODE_QUESTION

Scope

public Scope(ComponentName component,
             ResId module,
             int mode,
             Locale locale)
Parameters:
component - Component pair of mapping
module - Module pair of mapping
mode - Scope's mode
locale - Scope's locale or null for assistant's default locale.
Throws:
IllegalArgumentException - if mode contains MODE_FOREIGN and locale is null or has empty language code.
See Also:
MODE_MODAL, MODE_FOREIGN, MODE_QUESTION
Method Detail

getMode

public int getMode()
Returns mode for this scope passed to constructor.

Returns:
Mode for this scope
See Also:
MODE_MODAL, MODE_FOREIGN, MODE_QUESTION, Scope(ComponentName, ResId, int), Scope(ComponentName, ResId, int, Locale)

getComponent

public ComponentName getComponent()
Returns component for this scope passed to constructor.

Returns:
Component for this scope
See Also:
Scope(ComponentName, ResId, int), Scope(ComponentName, ResId, int, Locale)

getModuleResource

public ResId getModuleResource()
Returns module id for this scope passed to constructor.

Returns:
module id for this scope
See Also:
Scope(ComponentName, ResId, int), Scope(ComponentName, ResId, int, Locale)

getLocale

public Locale getLocale()
Returns locale for this scope passed to Scope(ComponentName, ResId, int, Locale). Returns null for not foreign scopes.

See Also:
MODE_FOREIGN

readFromParcel

public static Scope readFromParcel(Parcel parcel)

writeToParcel

public static void writeToParcel(Scope scope,
                                 Parcel parcel,
                                 int flags)