org.apache.lenya.workflow.impl
Class WorkflowBuilder

java.lang.Object
  extended by org.apache.lenya.workflow.impl.WorkflowBuilder

public class WorkflowBuilder
extends java.lang.Object

Utility class to build a workflow schema from a file.


Field Summary
protected static java.lang.String ACTION_ELEMENT
           
protected static java.lang.String ASSIGNMENT_ELEMENT
           
protected static java.lang.String CLASS_ATTRIBUTE
           
protected static java.lang.String CONDITION_ELEMENT
           
protected static java.lang.String DESTINATION_ATTRIBUTE
           
protected static java.lang.String EVENT_ELEMENT
           
protected static java.lang.String ID_ATTRIBUTE
           
protected static java.lang.String INITIAL_ATTRIBUTE
           
protected static java.lang.String NAME_ATTRIBUTE
           
protected static java.lang.String SOURCE_ATTRIBUTE
           
protected static java.lang.String STATE_ELEMENT
           
protected static java.lang.String SYNCHRONIZED_ATTRIBUTE
           
protected static java.lang.String TRANSITION_ELEMENT
           
protected static java.lang.String VALUE_ATTRIBUTE
           
protected static java.lang.String VARIABLE_ATTRIBUTE
           
protected static java.lang.String VARIABLE_ELEMENT
           
 
Constructor Summary
protected WorkflowBuilder()
          Ctor.
 
Method Summary
protected static Action buildAction(org.w3c.dom.Element element)
          Builds an action from an XML element.
protected static BooleanVariableAssignmentImpl buildAssignment(java.util.Map variables, org.w3c.dom.Element element)
          Builds an assignment object from an XML element.
protected static Condition buildCondition(org.w3c.dom.Element element)
          Builds a condition from an XML element.
protected static EventImpl buildEvent(org.w3c.dom.Element element)
          Builds an event from an XML element.
protected static StateImpl buildState(org.w3c.dom.Element element)
          Builds a state from an XML element.
protected static TransitionImpl buildTransition(org.w3c.dom.Element element, java.util.Map states, java.util.Map events, java.util.Map variables)
          Builds a transition from an XML element.
protected static BooleanVariableImpl buildVariable(org.w3c.dom.Element element)
          Builds a boolean variable from an XML element.
protected static WorkflowImpl buildWorkflow(org.w3c.dom.Document document)
          Builds a workflow object from an XML document.
static WorkflowImpl buildWorkflow(java.io.File file)
          Builds a workflow schema from a file.
protected static boolean isInitialStateElement(org.w3c.dom.Element element)
          Checks if a state element contains the initial state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_ELEMENT

protected static final java.lang.String STATE_ELEMENT
See Also:
Constant Field Values

TRANSITION_ELEMENT

protected static final java.lang.String TRANSITION_ELEMENT
See Also:
Constant Field Values

EVENT_ELEMENT

protected static final java.lang.String EVENT_ELEMENT
See Also:
Constant Field Values

CONDITION_ELEMENT

protected static final java.lang.String CONDITION_ELEMENT
See Also:
Constant Field Values

ACTION_ELEMENT

protected static final java.lang.String ACTION_ELEMENT
See Also:
Constant Field Values

ID_ATTRIBUTE

protected static final java.lang.String ID_ATTRIBUTE
See Also:
Constant Field Values

INITIAL_ATTRIBUTE

protected static final java.lang.String INITIAL_ATTRIBUTE
See Also:
Constant Field Values

SOURCE_ATTRIBUTE

protected static final java.lang.String SOURCE_ATTRIBUTE
See Also:
Constant Field Values

DESTINATION_ATTRIBUTE

protected static final java.lang.String DESTINATION_ATTRIBUTE
See Also:
Constant Field Values

CLASS_ATTRIBUTE

protected static final java.lang.String CLASS_ATTRIBUTE
See Also:
Constant Field Values

VARIABLE_ELEMENT

protected static final java.lang.String VARIABLE_ELEMENT
See Also:
Constant Field Values

ASSIGNMENT_ELEMENT

protected static final java.lang.String ASSIGNMENT_ELEMENT
See Also:
Constant Field Values

VARIABLE_ATTRIBUTE

protected static final java.lang.String VARIABLE_ATTRIBUTE
See Also:
Constant Field Values

VALUE_ATTRIBUTE

protected static final java.lang.String VALUE_ATTRIBUTE
See Also:
Constant Field Values

NAME_ATTRIBUTE

protected static final java.lang.String NAME_ATTRIBUTE
See Also:
Constant Field Values

SYNCHRONIZED_ATTRIBUTE

protected static final java.lang.String SYNCHRONIZED_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

WorkflowBuilder

protected WorkflowBuilder()
Ctor.

Method Detail

buildWorkflow

public static WorkflowImpl buildWorkflow(java.io.File file)
                                  throws WorkflowException
Builds a workflow schema from a file.

Parameters:
file - The file.
Returns:
A workflow schema implementation.
Throws:
WorkflowException - if the file does not represent a valid workflow schema.

buildWorkflow

protected static WorkflowImpl buildWorkflow(org.w3c.dom.Document document)
                                     throws javax.xml.parsers.ParserConfigurationException,
                                            org.xml.sax.SAXException,
                                            java.io.IOException,
                                            WorkflowException
Builds a workflow object from an XML document.

Parameters:
document - The XML document.
Returns:
A workflow implementation.
Throws:
javax.xml.parsers.ParserConfigurationException - when something went wrong.
org.xml.sax.SAXException - when something went wrong.
java.io.IOException - when something went wrong.
WorkflowException - when something went wrong.

isInitialStateElement

protected static boolean isInitialStateElement(org.w3c.dom.Element element)
Checks if a state element contains the initial state.

Parameters:
element - An XML element.
Returns:
A boolean value.

buildState

protected static StateImpl buildState(org.w3c.dom.Element element)
Builds a state from an XML element.

Parameters:
element - An XML element.
Returns:
A state.

buildTransition

protected static TransitionImpl buildTransition(org.w3c.dom.Element element,
                                                java.util.Map states,
                                                java.util.Map events,
                                                java.util.Map variables)
                                         throws WorkflowException
Builds a transition from an XML element.

Parameters:
element - An XML element.
states - A map from state IDs to states.
events - A map from event IDs to events.
variables - A map from variable names to variables.
Returns:
A transition.
Throws:
WorkflowException - when something went wrong.

buildEvent

protected static EventImpl buildEvent(org.w3c.dom.Element element)
Builds an event from an XML element.

Parameters:
element - An XML element.
Returns:
An event.

buildCondition

protected static Condition buildCondition(org.w3c.dom.Element element)
                                   throws WorkflowException
Builds a condition from an XML element.

Parameters:
element - An XML element.
Returns:
A condition.
Throws:
WorkflowException - when something went wrong.

buildAction

protected static Action buildAction(org.w3c.dom.Element element)
Builds an action from an XML element.

Parameters:
element - An XML element.
Returns:
An action.

buildVariable

protected static BooleanVariableImpl buildVariable(org.w3c.dom.Element element)
Builds a boolean variable from an XML element.

Parameters:
element - An XML element.
Returns:
A boolean variable.

buildAssignment

protected static BooleanVariableAssignmentImpl buildAssignment(java.util.Map variables,
                                                               org.w3c.dom.Element element)
                                                        throws WorkflowException
Builds an assignment object from an XML element.

Parameters:
variables - A map from variable names to variables.
element - An XML element.
Returns:
An assignment object.
Throws:
WorkflowException - when something went wrong.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.