Cisco Cisco Unified Customer Voice Portal 11.0(1) Developer's Guide

Page of 79
A
PPENDIX 
A:
 
T
HE 
V
OICE 
F
OUNDATION 
C
LASSES
 
 
C
ISCO 
CVP V
OICE
XML 3.1
 
 
  
Programmer 
Guide 
 
The following Java code demonstrates the concepts described above: 
VPreference pref = ved.getPreference(); 
VForm form = VForm.getNew(pref, "start"); 
Here, the 
VPreference
 object is obtained from the 
VoiceElementData
 object passed as input to 
a voice element. It is used to create a 
VForm
 object. Assuming the application is using the voice 
browser Foo, that choice is reflected in the 
VPreference
 object and therefore the 
getNew
 factory 
method returns a 
VFormFoo
 object, which is automatically downcasted to a 
VForm
 object. The 
developer then uses the form object as desired. 
This ability to treat all objects returned as a root VFC object is not available when the developer 
wishes to use functionality that exists either in a particular version of VoiceXML or a particular 
voice browser. The developer must understand that doing so would prevent their code from 
functioning on all voice browsers. In this case, the developer simply treats the return of the 
factory method as a class higher in the class hierarchy (
VFormV2
 or 
VFormFoo
 in the example in 
The following Java code demonstrates this: 
VGrammar myGrammar = VGrammar.getNew(pref); 
((VGrammarV2) myGrammar).setMaxage(1000); 
 
The 
setMaxage
 method exists only in the 
VGrammarV2
 class since this is a feature that exists only 
in VoiceXML 2.0. To call this method, one must first upcast the previously downcasted object 
back to 
VGrammarV2
. If this is not done, an exception will be thrown indicating that 
VGrammar
 
does not have a method named 
setMaxage
. Also note that if the user in Studio chose a voice 
browser that was compatible with VoiceXML 1.0 only, a runtime exception would be thrown 
when this code is encountered because that browser would be unable to understand VoiceXML 
referring to maxage. 
VFC Classes 
The following lists all the VFC classes (with full package names) and briefly explains what they 
are responsible for. The Javadocs for the VFCs provide significantly more detail about the 
classes, their methods, and how they are used. 
• 
com.audium.core.vfc.util.VMain. 
This object is the container for a complete VoiceXML 
document. It includes methods for managing information about the page such as the meta 
tags, the doc type, and the value to put in the 
<vxml>
 tag’s 
xml:lang
 attribute. It includes 
methods for adding document-scope data such as links, variables, and VoiceXML properties. 
VForm
 objects are added to this object to create the VoiceXML page. CVP VoiceXML Server 
uses the 
VMain
 object to handle the printing of the VoiceXML page. Voice elements receive 
an instantiated 
VMain
 object as input and the developer need only worry about filling the 
object with the appropriate content. 
 
 
Copyright 2001 - 2005 Audium Corporation.  All Rights Reserved. 10/05
 
75