de.dfki.lt.mary
Class MaryData

java.lang.Object
  extended by de.dfki.lt.mary.MaryData

public class MaryData
extends java.lang.Object

A representation of any type of mary data, be it input, intermediate or output data. The "technical" representation of the read data is hidden from the caller, but can be accessed on request. Internally, the data is appropriately represented according to this data's type, i.e. as a String containing plain text, an XML DOM tree, or an input stream containing audio data.

Author:
Marc Schröder

Constructor Summary
MaryData(MaryDataType type)
           
MaryData(MaryDataType type, boolean createStubDocument)
           
 
Method Summary
 void append(MaryData md)
           
 void appendAudio(javax.sound.sampled.AudioInputStream audioToAppend)
          For audio data, append more audio data to the one currently present.
 javax.sound.sampled.AudioInputStream getAudio()
           
 javax.sound.sampled.AudioFileFormat getAudioFileFormat()
           
 java.lang.Object getData()
           
 java.lang.String getDefaultEffects()
           
 java.lang.String getDefaultStyle()
           
 Voice getDefaultVoice()
           
 org.w3c.dom.Document getDocument()
           
 java.lang.String getPlainText()
           
 java.util.List getUtterances()
           
 boolean getValidating()
           
 boolean getWarnClient()
           
 void readFrom(java.io.InputStream is)
          Read data from input stream is, in the appropriate way as determined by our type.
 void readFrom(java.io.InputStream is, java.lang.String endMarker)
          Read data from input stream is, in the appropriate way as determined by our type.
 void readFrom(java.io.Reader from)
          Read data from reader r in the appropriate way as determined by our type.
 void readFrom(java.io.Reader from, java.lang.String endMarker)
          Read data from reader r in the appropriate way as determined by our type.
 void setAudio(javax.sound.sampled.AudioInputStream audio)
          Set the audio data.
 void setAudioFileFormat(javax.sound.sampled.AudioFileFormat audioFileFormat)
          The audio file format is required only for data types serving as input to modules producing AUDIO data (e.g., MBROLA data), as well as for the AUDIO data itself.
 void setDefaultEffects(java.lang.String effects)
           
 void setDefaultStyle(java.lang.String style)
           
 void setDefaultVoice(Voice voice)
           
 void setDocument(org.w3c.dom.Document xmlDocument)
           
 void setPlainText(java.lang.String plainText)
           
 void setUtterances(java.util.List utterances)
           
 void setValidating(boolean doValidate)
           
 void setWarnClient(boolean doWarnClient)
           
 MaryDataType type()
           
 void writeTo(java.io.OutputStream os)
          Write our internal representation to output stream os, in the appropriate way as determined by our type.
 void writeTo(java.io.Writer w)
          Write our internal representation to writer w, in the appropriate way as determined by our type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaryData

public MaryData(MaryDataType type)

MaryData

public MaryData(MaryDataType type,
                boolean createStubDocument)
Method Detail

getValidating

public boolean getValidating()

setValidating

public void setValidating(boolean doValidate)
                   throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException

getWarnClient

public boolean getWarnClient()

setWarnClient

public void setWarnClient(boolean doWarnClient)

type

public MaryDataType type()

readFrom

public void readFrom(java.io.InputStream is)
              throws javax.xml.parsers.ParserConfigurationException,
                     org.xml.sax.SAXException,
                     java.io.IOException,
                     javax.xml.transform.TransformerConfigurationException,
                     javax.xml.transform.TransformerException
Read data from input stream is, in the appropriate way as determined by our type.

Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

readFrom

public void readFrom(java.io.InputStream is,
                     java.lang.String endMarker)
              throws javax.xml.parsers.ParserConfigurationException,
                     org.xml.sax.SAXException,
                     java.io.IOException,
                     javax.xml.transform.TransformerConfigurationException,
                     javax.xml.transform.TransformerException
Read data from input stream is, in the appropriate way as determined by our type.

Parameters:
is - the InputStream from which to read.
endMarker - a string marking end of file. If this is null, read until end-of-file; if it is non-null, read up to (and including) the first line containing the end marker string. This will be ignored for audio data.
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

readFrom

public void readFrom(java.io.Reader from)
              throws javax.xml.parsers.ParserConfigurationException,
                     org.xml.sax.SAXException,
                     java.io.IOException,
                     javax.xml.transform.TransformerConfigurationException,
                     javax.xml.transform.TransformerException
Read data from reader r in the appropriate way as determined by our type. Only XML and Text data can be read from a reader, audio data cannot. "Helpers" needed to read the data, such as XML parser objects, are created when they are needed. If doWarnClient is set to true, warning and error messages related to XML parsing are logged to the log category connected to the client from which this request originated.

Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

readFrom

public void readFrom(java.io.Reader from,
                     java.lang.String endMarker)
              throws javax.xml.parsers.ParserConfigurationException,
                     org.xml.sax.SAXException,
                     java.io.IOException,
                     javax.xml.transform.TransformerConfigurationException,
                     javax.xml.transform.TransformerException
Read data from reader r in the appropriate way as determined by our type. Only XML and Text data can be read from a reader, audio data cannot. "Helpers" needed to read the data, such as XML parser objects, are created when they are needed. If doWarnClient is set to true, warning and error messages related to XML parsing are logged to the log category connected to the client from which this request originated.

Parameters:
from - the Reader from which to read.
endMarker - a string marking end of file. If this is null, read until end-of-file; if it is non-null, read up to (and including) the first line containing the end marker string.
Throws:
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
javax.xml.transform.TransformerConfigurationException
javax.xml.transform.TransformerException

writeTo

public void writeTo(java.io.OutputStream os)
             throws javax.xml.transform.TransformerConfigurationException,
                    java.io.FileNotFoundException,
                    javax.xml.transform.TransformerException,
                    java.io.IOException,
                    java.lang.Exception
Write our internal representation to output stream os, in the appropriate way as determined by our type.

Throws:
javax.xml.transform.TransformerConfigurationException
java.io.FileNotFoundException
javax.xml.transform.TransformerException
java.io.IOException
java.lang.Exception

writeTo

public void writeTo(java.io.Writer w)
             throws javax.xml.transform.TransformerConfigurationException,
                    java.io.FileNotFoundException,
                    javax.xml.transform.TransformerException,
                    java.io.IOException,
                    java.lang.Exception
Write our internal representation to writer w, in the appropriate way as determined by our type. Only XML and Text data can be written to a writer, audio data cannot. "Helpers" needed to read the data, such as XML parser objects, are created when they are needed.

Throws:
javax.xml.transform.TransformerConfigurationException
java.io.FileNotFoundException
javax.xml.transform.TransformerException
java.io.IOException
java.lang.Exception

getData

public java.lang.Object getData()

getPlainText

public java.lang.String getPlainText()

setPlainText

public void setPlainText(java.lang.String plainText)

getDocument

public org.w3c.dom.Document getDocument()

setDocument

public void setDocument(org.w3c.dom.Document xmlDocument)

getAudio

public javax.sound.sampled.AudioInputStream getAudio()

setAudio

public void setAudio(javax.sound.sampled.AudioInputStream audio)
Set the audio data. This will discard any previously set audio data. If audio data is to be appended, consider appendAudio().

Parameters:
audio -

getUtterances

public java.util.List getUtterances()

setUtterances

public void setUtterances(java.util.List utterances)

setDefaultVoice

public void setDefaultVoice(Voice voice)

getDefaultVoice

public Voice getDefaultVoice()

setDefaultStyle

public void setDefaultStyle(java.lang.String style)

getDefaultStyle

public java.lang.String getDefaultStyle()

setDefaultEffects

public void setDefaultEffects(java.lang.String effects)

getDefaultEffects

public java.lang.String getDefaultEffects()

setAudioFileFormat

public void setAudioFileFormat(javax.sound.sampled.AudioFileFormat audioFileFormat)
The audio file format is required only for data types serving as input to modules producing AUDIO data (e.g., MBROLA data), as well as for the AUDIO data itself. It should be set by the calling code before passing the data to the module producing AUDIO data.


getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat()

append

public void append(MaryData md)

appendAudio

public void appendAudio(javax.sound.sampled.AudioInputStream audioToAppend)
For audio data, append more audio data to the one currently present. If no audio data is set yet, this call is equivalent to setAudio().

Parameters:
audioToAppend - the new audio data to append