public class MaryCache extends Object
Constructor and Description |
---|
MaryCache(File cacheFile,
boolean clearCache)
Create a MaryCache with the given file prefix.
|
Modifier and Type | Method and Description |
---|---|
static MaryCache |
getCache()
Try to get the MaryCache object.
|
static boolean |
haveCache()
Indicate whether there is a MaryCache currently available.
|
void |
insertAudio(String inputtype,
String locale,
String voice,
String inputtext,
byte[] audio)
Insert a record of a MARY request producing data of output type AUDIO into the cache.
|
void |
insertAudio(String inputtype,
String locale,
String voice,
String outputparams,
String style,
String effects,
String inputtext,
byte[] audio)
Insert a record of a MARY request producing data of output type AUDIO into the cache.
|
void |
insertText(String inputtype,
String outputtype,
String locale,
String voice,
String inputtext,
String outputtext)
Insert a record of a MARY request producing data of type text into the cache.
|
void |
insertText(String inputtype,
String outputtype,
String locale,
String voice,
String outputparams,
String style,
String effects,
String inputtext,
String outputtext)
Insert a record of a MARY request producing data of type text into the cache.
|
byte[] |
lookupAudio(String inputtype,
String locale,
String voice,
String inputtext)
Carry out a lookup in the cache with the given parameters, for a request with output type AUDIO.
|
byte[] |
lookupAudio(String inputtype,
String locale,
String voice,
String outputparams,
String style,
String effects,
String inputtext)
Carry out a lookup in the cache with the given parameters, for a request with output type AUDIO.
|
String |
lookupText(String inputtype,
String outputtype,
String locale,
String voice,
String inputtext)
Carry out a lookup in the cache with the given parameters.
|
String |
lookupText(String inputtype,
String outputtype,
String locale,
String voice,
String outputparams,
String style,
String effects,
String inputtext)
Carry out a lookup in the cache with the given parameters.
|
static void |
main(String[] args) |
void |
shutdown()
Shut down the cache.
|
public MaryCache(File cacheFile, boolean clearCache) throws ClassNotFoundException, SQLException
getCache()
instead. TODO: Find a more elegant way to create a custom MaryCache from test
code.cacheFile
- the file name prefix with which to create the cache database.clearCache
- if true, clear the cache; if false, keep it.ClassNotFoundException
- if the HSQL JDBC driver is not in the classpath.SQLException
- if the database connection cannot be set uppublic static MaryCache getCache()
if you just want to check if the cache exists.
To the extent possible this method gives the no-throw guarantee: if the cache cannot be created, null will be returned
and any exception will be logged.
public static boolean haveCache()
public void insertText(String inputtype, String outputtype, String locale, String voice, String inputtext, String outputtext) throws SQLException
inputtype
- the request's input type. Must not be null.outputtype
- the request's output type, which must be a text type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.inputtext
- the request's input text. Must not be null.outputtext
- the request's output text. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if the record could not be entered into the cache.public void insertText(String inputtype, String outputtype, String locale, String voice, String outputparams, String style, String effects, String inputtext, String outputtext) throws SQLException
inputtype
- the request's input type. Must not be null.outputtype
- the request's output type, which must be a text type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.outputparams
- optionally, any output parameters. Can be null.style
- optionally, any style. Can be null.effects
- optionally, any effects. Can be null.inputtext
- the request's input text. Must not be null.outputtext
- the request's output text. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if the record could not be entered into the cache.public void insertAudio(String inputtype, String locale, String voice, String inputtext, byte[] audio) throws SQLException
inputtype
- the request's input type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.inputtext
- the request's input text. Must not be null.audio
- the request's output data. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if the record could not be entered into the cache.public void insertAudio(String inputtype, String locale, String voice, String outputparams, String style, String effects, String inputtext, byte[] audio) throws SQLException
inputtype
- the request's input type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.outputparams
- optionally, any output parameters. Can be null.style
- optionally, any style. Can be null.effects
- optionally, any effects. Can be null.inputtext
- the request's input text. Must not be null.audio
- the request's output data. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if the record could not be entered into the cache.public String lookupText(String inputtype, String outputtype, String locale, String voice, String inputtext) throws SQLException
inputtype
- the request's input type. Must not be null.outputtype
- the request's output type, which must be a text type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.inputtext
- the request's input text. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if there is a problem querying the cache.public String lookupText(String inputtype, String outputtype, String locale, String voice, String outputparams, String style, String effects, String inputtext) throws SQLException
inputtype
- the request's input type. Must not be null.outputtype
- the request's output type, which must be a text type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.outputparams
- optionally, any output parameters. Can be null.style
- optionally, any style. Can be null.effects
- optionally, any effects. Can be null.inputtext
- the request's input text. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if there is a problem querying the cache.public byte[] lookupAudio(String inputtype, String locale, String voice, String inputtext) throws SQLException
inputtype
- the request's input type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.inputtext
- the request's input text. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if there is a problem querying the cache.public byte[] lookupAudio(String inputtype, String locale, String voice, String outputparams, String style, String effects, String inputtext) throws SQLException
inputtype
- the request's input type. Must not be null.locale
- the locale of the request. Must not be null.voice
- the voice of the request. Can be null.outputparams
- optionally, any output parameters. Can be null.style
- optionally, any style. Can be null.effects
- optionally, any effects. Can be null.inputtext
- the request's input text. Must not be null.NullPointerException
- if one of the fields is null which must be non-null.SQLException
- if there is a problem querying the cache.public void shutdown() throws SQLException
SQLException
- if there is a problem executing the database SHUTDOWN command.public static void main(String[] args) throws SQLException, MalformedURLException, ClassNotFoundException
args
- argsSQLException
- SQLExceptionMalformedURLException
- MalformedURLExceptionClassNotFoundException
- ClassNotFoundExceptionCopyright © 2000–2016 DFKI GmbH. All rights reserved.