org.apache.shale.dialog.scxml.config
Class ConfigurationParser

java.lang.Object
  extended by org.apache.shale.dialog.scxml.config.ConfigurationParser

public final class ConfigurationParser
extends Object

Configuration utility for parsing SCXML documents as resources for defining dialogs. This class has no dependencies on web tier APIs, only on the Commons SCXML state machine engine library, and on the parsing technology (Commons Digester) being used.

The configuration for each Shale dialog exists as a standalone SCXML document, with additional dialog "metadata" file(s) that serve as the entry point for the Shale Dialog Manager.

These dialog-config.xml file(s) look like this:

 <dialogs>
     <dialog name="Foo" scxmlconfig="foo.scxml" />
     <dialog name="Bar" scxmlconfig="bar.scxml"
             dataclassname="org.apache.shale.examples.Bar" />
     <dialog name="Baz" scxmlconfig="baz.scxml" />
     <!-- etc. -->
 </dialogs>
 

To use this utility, instantiate a new instance and set the dialogs, resource, and validating properties. Then, call the parse() method. You can parse more than one resource by resetting the resource property and calling parse() again.

Since:
1.0.4

Constructor Summary
ConfigurationParser()
           
 
Method Summary
 Map getDialogs()
          Return the Map of Dialog instances into which parsed information will be stored, keyed by dialog name.
 URL getResource()
          Return the URL of the configuration resource to be parsed.
 boolean isValidating()
          Return a flag indicating whether we will be doing a validating parse or not.
 void parse()
          Parse the configuration resource identified by the resource property, storing resulting information in the Map specified by the dialogs property.
 void setDialogs(Map dialogs)
          Set the Map of Dialog instances into which parsed information will be stored, keyed by dialog name.
 void setResource(URL resource)
          Set the URL of the configuration resource to be parsed.
 void setValidating(boolean validating)
          Set a flag indicating whether we will be doing a validating parse or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationParser

public ConfigurationParser()
Method Detail

getDialogs

public Map getDialogs()

Return the Map of Dialog instances into which parsed information will be stored, keyed by dialog name.

Returns:
Map of SCXML instances, keyed by logical dialog name

setDialogs

public void setDialogs(Map dialogs)

Set the Map of Dialog instances into which parsed information will be stored, keyed by dialog name.

Parameters:
dialogs - The new map

getResource

public URL getResource()

Return the URL of the configuration resource to be parsed.

Returns:
The resource URL

setResource

public void setResource(URL resource)

Set the URL of the configuration resource to be parsed.

Parameters:
resource - The new resource URL

isValidating

public boolean isValidating()

Return a flag indicating whether we will be doing a validating parse or not. Default value is false.

Returns:
Whether the parse is validating

setValidating

public void setValidating(boolean validating)

Set a flag indicating whether we will be doing a validating parse or not.

Parameters:
validating - New flag value

parse

public void parse()
           throws IOException,
                  SAXException

Parse the configuration resource identified by the resource property, storing resulting information in the Map specified by the dialogs property.

Throws:
IOException - if an input/output error occurs
SAXException - if an XML parsing error occurs


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.