org.speakright.core
Class SRLocations

java.lang.Object
  extended by org.speakright.core.SRLocations
All Implemented Interfaces:
java.io.Serializable

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

Each SpeakRight application has a project directory that contains the various xml config files, and usually audio and grammar sub-dirs.

 c:\myapp            project dir
   |- audio          audio dir. contains audio files for the default
                     language, which is usually en-us.
      |- fr-ca       audio files for French Canadian locale
      |- sp-sp       audio files for Spanish locale
   |- grammar        grammar dir.  contains grammar files for the default
                     language which is usually en-us.
      |- fr-ca       grammar files for French Canadian locale
      |- sp-sp       grammar files for Spanish locale
   |- sro            xml files
      |- audio
      |- grammar 
  

Author:
Ian Rae
See Also:
Serialized Form

Field Summary
 java.lang.String m_baseGrammarUrl
           
 java.lang.String m_basePromptUrl
           
 java.lang.String m_baseSROUrl
           
 
Constructor Summary
SRLocations()
           
 
Method Summary
static java.lang.String fixupDir(java.lang.String path)
          Ensures path ends in / (or \ on windows)
static java.lang.String fixupUrl(java.lang.String url)
          Ensure url ends in '/'
 java.lang.String getGrammarPath(java.lang.String language)
           
 java.lang.String getPromptPath(java.lang.String language)
           
 java.lang.String language()
          Get the current language
 java.lang.String makeFullGrammarUrl(java.lang.String url)
          Convert the URL of a grammar into a full (absolute) URL (using m_baseGrammarURL).
 java.lang.String makeFullPromptUrl(java.lang.String url)
          Convert the URL of a prompt into a full (absolute) URL (using m_basePromptURL).
 java.lang.String makeFullSROUrl(java.lang.String url)
          Convert the URL of a sro file or resource into a full (absolute) URL (using m_baseSROURL).
 java.lang.String projectDir()
          Get the project dir.
 java.lang.String resolvePath(java.lang.String path)
          Resolve the path.
 void setGrammarDir(java.lang.String path)
          sets the grammar dir.
 void setLanguage(java.lang.String s)
          Set the current language.
 void setProjectDir(java.lang.String path)
          sets the project dir and the grammar and audio directories.
 void setPromptDir(java.lang.String path)
          sets the prompt dir.
 void setSRODir(java.lang.String path)
          sets the SRO dir.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_baseGrammarUrl

public transient java.lang.String m_baseGrammarUrl

m_basePromptUrl

public transient java.lang.String m_basePromptUrl

m_baseSROUrl

public transient java.lang.String m_baseSROUrl
Constructor Detail

SRLocations

public SRLocations()
Method Detail

language

public java.lang.String language()
Get the current language

Returns:
language, such as "en-us"

setLanguage

public void setLanguage(java.lang.String s)
Set the current language.

Parameters:
s - language, such as "en-us"

projectDir

public java.lang.String projectDir()
Get the project dir. Each SpeakRight application can define one directory as the 'project dir', which holds the application and its resources such as grammar, audio, or xml files. Only used for unit testing?

Returns:

fixupDir

public static java.lang.String fixupDir(java.lang.String path)
Ensures path ends in / (or \ on windows)

Parameters:
path -
Returns:

resolvePath

public java.lang.String resolvePath(java.lang.String path)
Resolve the path. If it contains $sro$ then replace with the value of m_sroDir.

Parameters:
path - a full file path, such as "c:\\app3\\audio\\johnny.wav""
Returns:
a full file path with $sro$ resolved.

fixupUrl

public static java.lang.String fixupUrl(java.lang.String url)
Ensure url ends in '/'

Parameters:
url -
Returns:
url ending in '/'

makeFullPromptUrl

public java.lang.String makeFullPromptUrl(java.lang.String url)
Convert the URL of a prompt into a full (absolute) URL (using m_basePromptURL). If it's already a full URL then do nothing. Resolve $sro$ if present. Typically prompts are in {project-dir}/audio

Parameters:
url - a relative or absolute URL.
Returns:
a full (absolute) URL.

makeFullGrammarUrl

public java.lang.String makeFullGrammarUrl(java.lang.String url)
Convert the URL of a grammar into a full (absolute) URL (using m_baseGrammarURL). If it's already a full URL then do nothing. Resolve $sro$ if present. Typically grammars are in {project-dir}/grammar

Parameters:
url - a relative or absolute URL.
Returns:
a full (absolute) URL.

makeFullSROUrl

public java.lang.String makeFullSROUrl(java.lang.String url)
Convert the URL of a sro file or resource into a full (absolute) URL (using m_baseSROURL). If it's already a full URL then do nothing. Resolve $sro$ if present. Typically sro resourese are in {project-dir}/sro, with audio in {project-dir}/sro/audio, and grammar in {project-dir}/sro/grammar.

Parameters:
url - a relative or absolute URL.
Returns:
a full (absolute) URL.

setProjectDir

public void setProjectDir(java.lang.String path)
sets the project dir and the grammar and audio directories.

Parameters:
path - file path to the directory for this SpeakRight application

setPromptDir

public void setPromptDir(java.lang.String path)
sets the prompt dir. Call this after setProjectDir

Parameters:
path - file path to the directory containing audio files.

setGrammarDir

public void setGrammarDir(java.lang.String path)
sets the grammar dir. Call this after setProjectDir

Parameters:
path - file path to the directory containing grammar files.

setSRODir

public void setSRODir(java.lang.String path)
sets the SRO dir. Call this after setProjectDir

Parameters:
path - file path to the directory containing SRO audio, xml, and grammar files

getPromptPath

public java.lang.String getPromptPath(java.lang.String language)

getGrammarPath

public java.lang.String getGrammarPath(java.lang.String language)