org.jvoicexml.documentserver
Class JVoiceXmlDocumentServer

java.lang.Object
  extended by org.jvoicexml.documentserver.JVoiceXmlDocumentServer
All Implemented Interfaces:
DocumentServer

public final class JVoiceXmlDocumentServer
extends Object
implements DocumentServer

Basic implementation of a DocumentServer.

This implementation offers an extensible support for multiple schemes. All known handlers for schemes are held in a list of SchemeStrategys.

Version:
$Revision: 2888 $
Author:
Dirk Schnelle-Walka

Field Summary
 
Fields inherited from interface org.jvoicexml.DocumentServer
TEXT_PLAIN, TEXT_XML
 
Constructor Summary
JVoiceXmlDocumentServer()
          Creates a new object.
 
Method Summary
 void addSchemeStrategy(SchemeStrategy strategy)
          Adds the given scheme strategy.
 AudioInputStream getAudioInputStream(String sessionId, URI uri)
          Retrieves an AudioStream to the audio file with the given URI.
 VoiceXmlDocument getDocument(String sessionId, DocumentDescriptor descriptor)
          Gets the document with the given URI.
 GrammarDocument getGrammarDocument(String sessionId, URI uri, FetchAttributes attrs)
          Returns the external Grammar referenced by URI.
 Object getObject(String sessionId, DocumentDescriptor descriptor, String type)
          Retrieves an object of the given type from the given URI.
 void sessionClosed(String sessionId)
          Notification that the given session is closed.
 void setFetchAttributes(FetchAttributes attrs)
          Sets the default fetch attributes.
 void setSchemeStrategies(List<SchemeStrategy> schemeStrategies)
          Adds the given list of strategies for schemes to the supported schemes.
 URI storeAudio(AudioInputStream in)
          Stores the audio from the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JVoiceXmlDocumentServer

public JVoiceXmlDocumentServer()
Creates a new object.

This method should not be called by any application. Use JVoiceXml.getDocumentServer() to obtain a reference to the document server.

Method Detail

setSchemeStrategies

public void setSchemeStrategies(List<SchemeStrategy> schemeStrategies)
Adds the given list of strategies for schemes to the supported schemes.

Parameters:
schemeStrategies - List with strategies.
Since:
0.5

setFetchAttributes

public void setFetchAttributes(FetchAttributes attrs)
Sets the default fetch attributes.

Parameters:
attrs - default fetch attributes.
Since:
0.7

getDocument

public VoiceXmlDocument getDocument(String sessionId,
                                    DocumentDescriptor descriptor)
                             throws BadFetchError
Gets the document with the given URI.

Specified by:
getDocument in interface DocumentServer
Parameters:
sessionId - the Id of the current JVoiceXML session
descriptor - descriptor for the document to fetch.
Returns:
VoiceXML document with the given URI.
Throws:
BadFetchError - The URI does not reference a document or an error occurred retrieving the document.

addSchemeStrategy

public void addSchemeStrategy(SchemeStrategy strategy)
Adds the given scheme strategy.

Parameters:
strategy - Scheme strategy to be added.

getGrammarDocument

public GrammarDocument getGrammarDocument(String sessionId,
                                          URI uri,
                                          FetchAttributes attrs)
                                   throws BadFetchError
Returns the external Grammar referenced by URI.

If more than one grammar is available at the given URI, the grammar with the optional type is preferred. If preferredType is null, the ContentServer does not have to care about the preferredType.

Specified by:
getGrammarDocument in interface DocumentServer
Parameters:
sessionId - the Id of the current JVoiceXML session
uri - Where to find the grammar.
attrs - attributes governing the fetch.
Returns:
the grammar referenced by the URI.
Throws:
BadFetchError - The URI does not reference a document or an error occurred retrieving the document.

getAudioInputStream

public AudioInputStream getAudioInputStream(String sessionId,
                                            URI uri)
                                     throws BadFetchError
Retrieves an AudioStream to the audio file with the given URI.

Specified by:
getAudioInputStream in interface DocumentServer
Parameters:
sessionId - the Id of the current JVoiceXML session
uri - URI of the audio file.
Returns:
AudioInputStream for the audio file.
Throws:
BadFetchError - Error retrieving the audio file.

getObject

public Object getObject(String sessionId,
                        DocumentDescriptor descriptor,
                        String type)
                 throws BadFetchError
Retrieves an object of the given type from the given URI. Currently only text/plain and text/xml are supported.

Specified by:
getObject in interface DocumentServer
Parameters:
sessionId - the Id of the current JVoiceXML session
descriptor - descriptor for the document to fetch.
type - the type, e.g. text/plain.
Returns:
retrieved object
Throws:
BadFetchError - Error retrieving the object.

storeAudio

public URI storeAudio(AudioInputStream in)
               throws BadFetchError
Stores the audio from the given stream.

Specified by:
storeAudio in interface DocumentServer
Parameters:
in - stream to read the audio data from
Returns:
URI of the file.
Throws:
BadFetchError - Error writing.

sessionClosed

public void sessionClosed(String sessionId)
Notification that the given session is closed. Now the document server may free any resources related to the given session.

Specified by:
sessionClosed in interface DocumentServer
Parameters:
sessionId - the Id of the current JVoiceXML session.


Copyright © 2005-2010JVoiceXML group.