You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ra...@apache.org on 2005/08/21 05:24:37 UTC

svn commit: r234141 [1/4] - in /jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml: ./ env/ model/

Author: rahul
Date: Sat Aug 20 20:24:20 2005
New Revision: 234141

URL: http://svn.apache.org/viewcvs?rev=234141&view=rev
Log:
Corrected year in License and some 1500+ checkstyle errors.

Modified:
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Context.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Evaluator.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/EventDispatcher.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Observable.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/PathResolver.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLDigester.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExpressionException.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLHelper.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLListener.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLSemantics.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Status.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Step.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/TransitionTargetComparator.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/TriggerEvent.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/ELContext.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/ELEvaluator.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/RootContext.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/ServletContextResolver.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/SimpleDispatcher.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/Standalone.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/Tracer.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/URLResolver.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/env/package.html
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Action.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Assign.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Cancel.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Else.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/ElseIf.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Executable.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Exit.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/ExternalNode.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/History.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/If.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Initial.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Log.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/ModelException.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/OnEntry.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/OnExit.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Parallel.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Path.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/SCXML.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Send.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/State.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Transition.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/TransitionTarget.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/Var.java
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/model/package.html
    jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/package.html

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Context.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Context.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Context.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Context.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -21,65 +21,64 @@
 
 /**
  * A Context or "scope" for storing variables; usually tied to
- * a SCXML root or State object
- *
+ * a SCXML root or State object.
  */
 public interface Context {
     /**
      * Assigns a new value to an existing variable or creates a new one.
-     * The method searches the chain of parent Contexts for variable 
+     * The method searches the chain of parent Contexts for variable
      * existence.
-     * 
+     *
      * @param name The variable name
      * @param value The variable value
      */
-    public void set(String name, Object value);
+    void set(String name, Object value);
 
     /**
      * Assigns a new value to an existing variable or creates a new one.
-     * The method allows to shaddow a variable of the same name up the 
+     * The method allows to shaddow a variable of the same name up the
      * Context chain.
-     * 
+     *
      * @param name The variable name
      * @param value The variable value
      */
-    public void setLocal(String name, Object value);
+    void setLocal(String name, Object value);
 
     /**
-     * Get the value of this variable; delegating to parent
-     * 
+     * Get the value of this variable; delegating to parent.
+     *
      * @param name The name of the variable
      * @return The value (or null)
      */
-    public Object get(String name);
+    Object get(String name);
 
     /**
-     * Check if this variable exists, delegating to parent
-     * 
+     * Check if this variable exists, delegating to parent.
+     *
      * @param name The name of the variable
      * @return Whether a variable with the name exists in this Context
      */
-    public boolean has(String name);
+    boolean has(String name);
 
     /**
-     * Get an Iterator over all variables in this Context
-     * 
+     * Get an Iterator over all variables in this Context.
+     *
      * @return Local entries iterator (Map.Entry)
      * To get parent entries, call getParent().iterator().
      * @see #getParent()
      */
-    public Iterator iterator();
+    Iterator iterator();
 
     /**
-     * Clear this Context
+     * Clear this Context.
      */
-    public void reset();
+    void reset();
 
     /**
-     * Get the parent Context, may be null
-     * 
+     * Get the parent Context, may be null.
+     *
      * @return The parent Context in a chained Context environment
      */
-    public Context getParent();
+    Context getParent();
 
 }

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/ErrorReporter.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -21,63 +21,65 @@
  * An interface for reporting SCXML errors to the host environment,
  * containing the definition of commonly occuring errors while executing
  * SCXML documents.
- * 
+ *
  */
 public interface ErrorReporter {
 
     /**
+     * Handler for reporting an error.
+     *
      * @param errCode
      *            one of the ErrorReporter's constants
      * @param errDetail
      *            human readable description
      * @param errCtx
-     *            typically an SCXML element which caused an error, 
+     *            typically an SCXML element which caused an error,
      *            may be accompanied by additional information
      */
-    public void onError(String errCode, String errDetail, Object errCtx);
+    void onError(String errCode, String errDetail, Object errCtx);
 
     /**
      * Missing initial state for a composite state or for the smxml root.
-     * 
+     *
      * @see org.apache.commons.scxml.model.SCXML#getInitialState()
      * @see org.apache.commons.scxml.model.State#getInitial()
      */
-    public static final String NO_INITIAL = "NO_INITIAL";
-    
+    String NO_INITIAL = "NO_INITIAL";
+
     /**
-     * An initial state for a composite state whose Transition does not
+     * An initial state for a composite state whose Transition does not.
      * Map to a descendant of the composite state.
-     * 
+     *
      */
-    public static final String ILLEGAL_INITIAL = "ILLEGAL_INITIAL";
+    String ILLEGAL_INITIAL = "ILLEGAL_INITIAL";
 
     /**
-     * Unknown action - unsupported executable content. List of supported
+     * Unknown action - unsupported executable content. List of supported.
      * actions: assign, cancel, elseif, else, if, log, send, var
      */
-    public static final String UNKNOWN_ACTION = "UNKNOWN_ACTION";
-    
+    String UNKNOWN_ACTION = "UNKNOWN_ACTION";
+
     /**
      * Illegal state machine configuration.
-     * Either a parallel exists which does not have all its AND sub-states 
-     * active or there are multiple enabled OR states on the same level.  
+     * Either a parallel exists which does not have all its AND sub-states
+     * active or there are multiple enabled OR states on the same level.
      */
-    public static final String ILLEGAL_CONFIG = "ILLEGAL_CONFIG";
-    
+    String ILLEGAL_CONFIG = "ILLEGAL_CONFIG";
+
     /**
      * Non-deterministic situation has occured - there are more than
      * one enabled transitions in conflict.
      */
-    public static final String NON_DETERMINISTIC = "NON_DETERMINISTIC";
-    
+    String NON_DETERMINISTIC = "NON_DETERMINISTIC";
+
     /**
-     * A variable reffered to by assign@name is undefined.
+     * A variable referred to by assign name attribute is undefined.
      */
-    public static final String UNDEFINED_VARIABLE = "UNDEFINED_VARIABLE";
-    
+    String UNDEFINED_VARIABLE = "UNDEFINED_VARIABLE";
+
     /**
-     * An expression language error. 
+     * An expression language error.
      */
-    public static final String EXPRESSION_ERROR = "EXPRESSION_ERROR";
-    
+    String EXPRESSION_ERROR = "EXPRESSION_ERROR";
+
 }

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Evaluator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Evaluator.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Evaluator.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Evaluator.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -19,37 +19,37 @@
 
 /**
  * Interface for a component that may be used by the SCXML engines to
- * evaluate the expressions within the SCXML document. 
- * 
+ * evaluate the expressions within the SCXML document.
+ *
  */
 public interface Evaluator {
-    
+
     /**
-     * Evaluate an expression
-     * 
+     * Evaluate an expression.
+     *
      * @param ctx variable context
      * @param expr expression
      * @return a result of the evaluation
-     * @throws SCXMLExpressionException
+     * @throws SCXMLExpressionException A malformed exception
      */
-    public Object eval(Context ctx, String exp) throws SCXMLExpressionException;
+    Object eval(Context ctx, String expr) throws SCXMLExpressionException;
 
     /**
      * Create a new child context.
-     * 
+     *
      * @param parent parent context
      * @return new child context
      */
-    public Context newContext(Context parent);
+    Context newContext(Context parent);
 
     /**
      * Evaluate a condition.
-     * 
+     *
      * @param ctx variable context
      * @param expr expression
      * @return true/false
-     * @throws SCXMLExpressionException
+     * @throws SCXMLExpressionException A malformed exception
      */
-    public Boolean evalCond(Context ctx, String expr) throws SCXMLExpressionException;
-    
-}
\ No newline at end of file
+    Boolean evalCond(Context ctx, String expr) throws SCXMLExpressionException;
+
+}

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/EventDispatcher.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/EventDispatcher.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/EventDispatcher.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/EventDispatcher.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,22 +20,24 @@
 import java.util.Map;
 
 /**
- * The event controller interface used to send messages containing 
- * events or other information directly to another SCXML Interpreter, 
- * other external systems using an Event I/O Processor or to raise 
+ * The event controller interface used to send messages containing
+ * events or other information directly to another SCXML Interpreter,
+ * other external systems using an Event I/O Processor or to raise
  * events in the current SCXML session.
- * 
+ *
  */
 public interface EventDispatcher {
-    
+
     /**
-     * Cancel the specified send message
-     * 
+     * Cancel the specified send message.
+     *
      * @param sendId The ID of the send message to cancel
      */
-    public void cancel(String sendId);
+    void cancel(String sendId);
 
     /**
+     * Send this message to the target.
+     *
      * @param sendId The ID of the send message
      * @param target An expression returning the target location of the event
      * @param targetType The type of the Event I/O Processor that the event
@@ -43,11 +45,12 @@
      * @param event The type of event being generated.
      * @param params A list of zero or more whitespace separated variable
      *  names to be included with the event.
-     * @param hints The data containing information which may be 
+     * @param hints The data containing information which may be
      *  used by the implementing platform to configure the event processor
      * @param delay The event is dispatched after the delay interval elapses
      */
-    public void send(String sendId, String target, String targetType,
+    void send(String sendId, String target, String targetType,
             String event, Map params, Object hints, long delay);
-    
+
 }
+

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/NotificationRegistry.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,6 +20,8 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.scxml.model.Transition;
 import org.apache.commons.scxml.model.TransitionTarget;
@@ -28,28 +30,32 @@
  * The registry where SCXML listeners are recorded for Observable
  * objects. The registry performs book keeping functions and notifies
  * all listeners of the events of interest.
- * 
+ *
  */
 public class NotificationRegistry {
-    
-    private HashMap regs = new HashMap();
-    
+
+    /**
+     * The Map of all listeners keyed by Observable.
+     */
+    private Map regs = new HashMap();
+
     /**
-     * Constructor
+     * Constructor.
      */
-    public NotificationRegistry(){
+    public NotificationRegistry() {
         super();
     }
-    
+
     /**
-     * Register this SCXMLListener for this Observable
-     * 
-     * @param source The observable this listener wants to listen to 
+     * Register this SCXMLListener for this Observable.
+     *
+     * @param source The observable this listener wants to listen to
      * @param lst The listener
      */
-    public void addListener(Observable source, SCXMLListener lst) {
-        HashSet entries = (HashSet)regs.get(source);
-        if(entries == null) {
+    public final void addListener(final Observable source,
+            final SCXMLListener lst) {
+        Set entries = (Set) regs.get(source);
+        if (entries == null) {
             entries = new HashSet();
             regs.put(source, entries);
         }
@@ -57,16 +63,17 @@
     }
 
     /**
-     * Deregister this SCXMLListener for this Observable
-     * 
+     * Deregister this SCXMLListener for this Observable.
+     *
      * @param source The observable this listener wants to stop listening to
      * @param lst The listener
      */
-    public void removeListener(Observable source, SCXMLListener lst) {
-        HashSet entries = (HashSet)regs.get(source);
-        if(entries != null) {
+    public final void removeListener(final Observable source,
+            final SCXMLListener lst) {
+        Set entries = (Set) regs.get(source);
+        if (entries != null) {
             entries.remove(lst);
-            if(entries.size() == 0){
+            if (entries.size() == 0) {
                 regs.remove(source);
             }
         }
@@ -74,16 +81,17 @@
 
     /**
      * Inform all relevant listeners that a TransitionTarget has been
-     * entered
-     * 
+     * entered.
+     *
      * @param source The Observable
      * @param state The TransitionTarget that was entered
      */
-    public void fireOnEntry(Observable source, TransitionTarget state) {
-        HashSet entries = (HashSet)regs.get(source);
-        if(entries != null) {
+    public final void fireOnEntry(final Observable source,
+            final TransitionTarget state) {
+        Set entries = (Set) regs.get(source);
+        if (entries != null) {
             for (Iterator iter = entries.iterator(); iter.hasNext();) {
-                SCXMLListener lst = (SCXMLListener)iter.next();
+                SCXMLListener lst = (SCXMLListener) iter.next();
                 lst.onEntry(state);
             }
         }
@@ -91,37 +99,40 @@
 
     /**
      * Inform all relevant listeners that a TransitionTarget has been
-     * exited
-     * 
+     * exited.
+     *
      * @param source The Observable
      * @param state The TransitionTarget that was exited
      */
-    public void fireOnExit(Observable source, TransitionTarget state) {
-        HashSet entries = (HashSet)regs.get(source);
-        if(entries != null) {
+    public final void fireOnExit(final Observable source,
+            final TransitionTarget state) {
+        Set entries = (Set) regs.get(source);
+        if (entries != null) {
             for (Iterator iter = entries.iterator(); iter.hasNext();) {
-                SCXMLListener lst = (SCXMLListener)iter.next();
+                SCXMLListener lst = (SCXMLListener) iter.next();
                 lst.onExit(state);
             }
         }
     }
 
     /**
-     * Inform all relevant listeners of a transition that has occured
-     * 
+     * Inform all relevant listeners of a transition that has occured.
+     *
      * @param source The Observable
      * @param from The source TransitionTarget
      * @param to The destination TransitionTarget
      * @param transition The Transition that was taken
      */
-    public void fireOnTransition(Observable source, TransitionTarget from,
-            TransitionTarget to, Transition transition) {
-        HashSet entries = (HashSet)regs.get(source);
-        if(entries != null) {
+    public final void fireOnTransition(final Observable source,
+            final TransitionTarget from, final TransitionTarget to,
+            final Transition transition) {
+        Set entries = (Set) regs.get(source);
+        if (entries != null) {
             for (Iterator iter = entries.iterator(); iter.hasNext();) {
-                SCXMLListener lst = (SCXMLListener)iter.next();
+                SCXMLListener lst = (SCXMLListener) iter.next();
                 lst.onTransition(from, to, transition);
             }
         }
     }
 }
+

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Observable.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Observable.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Observable.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/Observable.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,25 +20,26 @@
 /**
  * Interface that allows an entity within an SCXML document to have
  * listeners attached to itself so they may be informed of events within
- * this entity's realm.   
- * 
+ * this entity's realm.
+ *
  */
 public interface Observable {
-    
+
     /**
      * Add this SCXMLListener to the list of listeners associated
-     * with this SCXML model entity
-     * 
+     * with this SCXML model entity.
+     *
      * @param lst The listener to be added
      */
-    public void addListener(SCXMLListener lst);
+    void addListener(SCXMLListener lst);
 
     /**
      * Remove this SCXMLListener from the list of listeners associated
      * with this SCXML model entity.
-     * 
+     *
      * @param lst The listener to be removed
      */
-    public void removeListener(SCXMLListener lst);
+    void removeListener(SCXMLListener lst);
 
 }
+

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/PathResolver.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/PathResolver.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/PathResolver.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/PathResolver.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,24 +20,25 @@
 /**
  * Interface for a component that may be used by the SCXML engines
  * to resolve context sensitive paths.
- * 
+ *
  */
 public interface PathResolver {
 
     /**
      * Resolve this context sensitive path to an absolute URL.
-     * 
+     *
      * @param ctxPath Context sensitive path, can be a relative URL
      * @return Resolved path (an absolute URL) or <code>null</code>
      */
-    public String resolvePath(String ctxPath);
-    
+    String resolvePath(String ctxPath);
+
     /**
      * Get a PathResolver rooted at this context sensitive path.
-     * 
+     *
      * @param ctxPath Context sensitive path, can be a relative URL
      * @return Returns a new resolver rooted at ctxPath
      */
-    public PathResolver getResolver(String ctxPath);
+    PathResolver getResolver(String ctxPath);
 
 }
+

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLDigester.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLDigester.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLDigester.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLDigester.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -58,24 +58,20 @@
 import org.xml.sax.ErrorHandler;
 
 /**
- * The SCXMLDigester can be used to: <br>
+ * The SCXMLDigester provides the ability to digest a SCXML document into the
+ * Java object model provided in the model package.
+ * <br>
+ * The SCXMLDigester can be used for:
  * a) Digest a SCXML file placed in a web application context <br>
  * b) Obtain a Digester instance configured with rules for SCXML digestion <br>
  * c) Serialize an SCXML object (primarily for debugging) <br>
  */
 public class SCXMLDigester {
 
-    private static final String ERR_PARSE_FAIL = "<!-- Error parsing " +
-        "SCXML document for group: \"{0}\", with message: \"{1}\" -->\n";
-
-    // Logging
-    private static org.apache.commons.logging.Log log = LogFactory
-            .getLog(SCXMLDigester.class);
-
-    //-- PUBLIC METHODS --//
+    //---------------------- PUBLIC METHODS ----------------------//
     /**
      * API for standalone usage where the SCXML document is a URL.
-     * 
+     *
      * @param scxmlURL
      *            a canonical absolute URL to parse (relative URLs within the
      *            top level document are to be resovled against this URL).
@@ -90,14 +86,15 @@
      *            scripting engine)
      *
      * @return SCXML The SCXML object corresponding to the file argument
-     * 
+     *
      * @see Context
      * @see ErrorHandler
      * @see Evaluator
      * @see PathResolver
      */
-    public static SCXML digest(URL scxmlURL, ErrorHandler errHandler,
-            Context evalCtx, Evaluator evalEngine) {
+    public static SCXML digest(final URL scxmlURL,
+            final ErrorHandler errHandler, final Context evalCtx,
+            final Evaluator evalEngine) {
 
         SCXML scxml = null;
         Digester scxmlDigester = SCXMLDigester
@@ -107,9 +104,10 @@
         try {
             scxml = (SCXML) scxmlDigester.parse(scxmlURL.toString());
         } catch (Exception e) {
-            MessageFormat msgFormat = new MessageFormat(ERR_PARSE_FAIL);
-            String errMsg = msgFormat.format(new Object[] {scxmlURL.toString(),
-                    e.getMessage()});
+            MessageFormat msgFormat = new MessageFormat(ERR_DOC_PARSE_FAIL);
+            String errMsg = msgFormat.format(new Object[] {
+                scxmlURL.toString(), e.getMessage()
+            });
             log.error(errMsg, e);
         }
 
@@ -124,12 +122,12 @@
     /**
      * API for standalone usage where the SCXML document is a URI.
      * A PathResolver must be provided.
-     * 
+     *
      * @param pathResolver
      *            The PathResolver for this context
-     * @param documentRealPath 
+     * @param documentRealPath
      *            The String pointing to the absolute (real) path of the
-     *               SCXML config 
+     *               SCXML config
      * @param errHandler
      *            The SAX ErrorHandler
      * @param evalCtx
@@ -139,28 +137,29 @@
      *            the scripting/expression language engine for creating local
      *            state-level variable contexts (if supported by a given
      *            scripting engine)
-     * 
+     *
      * @return SCXML The SCXML object corresponding to the file argument
-     * 
+     *
      * @see Context
      * @see ErrorHandler
      * @see Evaluator
      * @see PathResolver
      */
-    public static SCXML digest(String documentRealPath, 
-            ErrorHandler errHandler, Context evalCtx, Evaluator evalEngine,
-            PathResolver pr) {
+    public static SCXML digest(final String documentRealPath,
+            final ErrorHandler errHandler, final Context evalCtx,
+            final Evaluator evalEngine, final PathResolver pathResolver) {
 
         SCXML scxml = null;
-        Digester scxmlDigester = SCXMLDigester.newInstance(null, pr);
+        Digester scxmlDigester = SCXMLDigester.newInstance(null, pathResolver);
         scxmlDigester.setErrorHandler(errHandler);
 
         try {
             scxml = (SCXML) scxmlDigester.parse(documentRealPath);
         } catch (Exception e) {
-            MessageFormat msgFormat = new MessageFormat(ERR_PARSE_FAIL);
-            String errMsg = msgFormat.format(new Object[] { documentRealPath,
-                e.getMessage()});
+            MessageFormat msgFormat = new MessageFormat(ERR_DOC_PARSE_FAIL);
+            String errMsg = msgFormat.format(new Object[] {
+                documentRealPath, e.getMessage()
+            });
             log.error(errMsg, e);
         }
 
@@ -173,13 +172,13 @@
     }
 
     /**
-     * Serialize this SCXML object (primarily for debugging)
-     * 
+     * Serialize this SCXML object (primarily for debugging).
+     *
      * @param scxml
      *            The SCXML to be serialized
      * @return String The serialized SCXML
      */
-    public static String serializeSCXML(SCXML scxml) {
+    public static String serializeSCXML(final SCXML scxml) {
         StringBuffer b = new StringBuffer("<scxml xmlns=\"").append(
                 scxml.getXmlns()).append("\" version=\"").append(
                 scxml.getVersion()).append("\" initialstate=\"").append(
@@ -193,86 +192,174 @@
         return b.toString();
     }
 
-    //-- PRIVATE CONSTANTS --//
+    //---------------------- PRIVATE CONSTANTS ----------------------//
     //// Patterns to get the digestion going
+    /** Root &lt;scxml&gt; element. */
     private static final String XP_SM = "scxml";
 
+    /** &lt;state&gt; children of root &lt;scxml&gt; element. */
     private static final String XP_SM_ST = "scxml/state";
 
     //// Universal matches
     // State
+    /** &lt;state&gt; children of &lt;state&gt; elements. */
     private static final String XP_ST_ST = "!*/state/state";
 
+    /** &lt;state&gt; children of &lt;parallel&gt; elements. */
     private static final String XP_PAR_ST = "!*/parallel/state";
 
+    /** &lt;state&gt; children of transition &lt;target&gt; elements. */
     private static final String XP_TR_TAR_ST = "!*/transition/target/state";
 
     //private static final String XP_ST_TAR_ST = "!*/state/target/state";
 
     // Parallel
+    /** &lt;parallel&gt; child of &lt;state&gt; elements. */
     private static final String XP_ST_PAR = "!*/state/parallel";
 
     // If
+    /** &lt;if&gt; element. */
     private static final String XP_IF = "!*/if";
 
     //// Path Fragments
     // Onentries and Onexits
+    /** &lt;onentry&gt; child element. */
     private static final String XP_ONEN = "/onentry";
 
+    /** &lt;onexit&gt; child element. */
     private static final String XP_ONEX = "/onexit";
 
     // Initial
+    /** &lt;initial&gt; child element. */
     private static final String XP_INI = "/initial";
-    
+
     // History
+    /** &lt;history&gt; child element. */
     private static final String XP_HIST = "/history";
 
     // Transition, target and exit
+    /** &lt;transition&gt; child element. */
     private static final String XP_TR = "/transition";
 
+    /** &lt;target&gt; child element. */
     private static final String XP_TAR = "/target";
 
+    /** &lt;state&gt; child element. */
     private static final String XP_ST = "/state";
 
+    /** &lt;exit&gt; child element. */
     private static final String XP_EXT = "/exit";
 
     // Actions
+    /** &lt;var&gt; child element. */
     private static final String XP_VAR = "/var";
 
+    /** &lt;assign&gt; child element. */
     private static final String XP_ASN = "/assign";
 
+    /** &lt;log&gt; child element. */
     private static final String XP_LOG = "/log";
 
+    /** &lt;send&gt; child element. */
     private static final String XP_SND = "/send";
 
+    /** &lt;cancel&gt; child element. */
     private static final String XP_CAN = "/cancel";
 
+    /** &lt;elseif&gt; child element. */
     private static final String XP_EIF = "/elseif";
 
+    /** &lt;else&gt; child element. */
     private static final String XP_ELS = "/else";
 
     //// Other constants
+    /** The indent to be used while serializing an SCXML object. */
     private static final String INDENT = " ";
 
-    //-- PRIVATE UTILITY METHODS --//
-    /*
-     * Get a SCXML digester instance
-     * 
+    /**
+     * Logger for SCXMLDigester.
+     */
+    private static org.apache.commons.logging.Log log = LogFactory
+            .getLog(SCXMLDigester.class);
+
+    // Error messages
+    /**
+     * Parsing SCXML document has failed.
+     * This message may be rendered hence wrapped in a comment.
+     */
+    private static final String ERR_DOC_PARSE_FAIL = "<!-- Error parsing "
+        + "SCXML document for group: \"{0}\", with message: \"{1}\" -->\n";
+
+    /**
+     * Error message when SCXML document specifies an illegal initial state.
+     */
+    private static final String ERR_SCXML_NO_INIT = "No SCXML child state "
+        + "with ID \"{0}\" found; illegal initialstate for SCXML document";
+
+    /**
+     * Error message when a state element specifies an initial state which
+     * cannot be found.
+     */
+    private static final String ERR_STATE_NO_INIT = "No initial element "
+        + "available for \"{0}\"";
+
+    /**
+     * Error message when a state element specifies an initial state which
+     * is not a direct descendent.
+     */
+    private static final String ERR_STATE_BAD_INIT = "Initial state "
+        + "null or not a descendant of \"{0}\"";
+
+    /**
+     * Error message when a referenced history state cannot be found.
+     */
+    private static final String ERR_STATE_NO_HIST = "Referenced history state "
+        + "null for \"{0}\"";
+
+    /**
+     * Error message when a shallow history state is not a child state.
+     */
+    private static final String ERR_STATE_BAD_SHALLOW_HIST = "History state"
+        + " for shallow history is not child for \"{0}\"";
+
+    /**
+     * Error message when a deep history state is not a descendent state.
+     */
+    private static final String ERR_STATE_BAD_DEEP_HIST = "History state"
+        + " for deep history is not descendant for \"{0}\"";
+
+    //---------------------- PRIVATE UTILITY METHODS ----------------------//
+    /**
+     * Get a SCXML digester instance.
+     *
+     * @param scxml The parent SCXML document if there is one (in case of
+     *              state templates for examples), null otherwise
+     * @param pr The PathResolver
      * @return Digester A newly configured SCXML digester instance
      */
-    private static Digester newInstance(SCXML scxml, PathResolver sc) {
+    private static Digester newInstance(final SCXML scxml,
+            final PathResolver pr) {
 
         Digester digester = new Digester();
         //Uncomment next line after SCXML DTD is available
         //digester.setValidating(true);
-        digester.setRules(initRules(scxml, sc));
+        digester.setRules(initRules(scxml, pr));
         return digester;
     }
 
     /*
-     * Private utility functions for configuring digester rule base for SCXML
+     * Private utility functions for configuring digester rule base for SCXML.
      */
-    private static ExtendedBaseRules initRules(SCXML scxml, PathResolver sc) {
+    /**
+     * Initialize the Digester rules for the current document.
+     *
+     * @param scxml The parent SCXML document (or null)
+     * @param pr The PathResolver
+     * @return ExtendedBaseRules The Digester rules configured for the
+     *                           current document
+     */
+    private static ExtendedBaseRules initRules(final SCXML scxml,
+            final PathResolver pr) {
 
         ExtendedBaseRules scxmlRules = new ExtendedBaseRules();
 
@@ -282,20 +369,17 @@
 
         //// States
         // Level one states
-        addStateRules(XP_SM_ST, scxmlRules, scxml, sc, 0);
+        addStateRules(XP_SM_ST, scxmlRules, scxml, pr, 0);
         scxmlRules.add(XP_SM_ST, new SetNextRule("addState"));
         // Nested states
-        addStateRules(XP_ST_ST, scxmlRules, scxml, sc, 1);
+        addStateRules(XP_ST_ST, scxmlRules, scxml, pr, 1);
         scxmlRules.add(XP_ST_ST, new SetNextRule("addChild"));
-        // Initial states (no longer needed due to addition of Initial)
-        //addStateRules(XP_ST_TAR_ST, scxmlRules, scxml, sc, 1);
-        //scxmlRules.add(XP_ST_TAR_ST, new SetNextRule("addChild"));
-        //scxmlRules.add(XP_ST_TAR_ST, new SetNextRule("setInitial"));
+
         // Parallel states
-        addStateRules(XP_PAR_ST, scxmlRules, scxml, sc, 1);
+        addStateRules(XP_PAR_ST, scxmlRules, scxml, pr, 1);
         scxmlRules.add(XP_PAR_ST, new SetNextRule("addState"));
         // Target states
-        addStateRules(XP_TR_TAR_ST, scxmlRules, scxml, sc, 2);
+        addStateRules(XP_TR_TAR_ST, scxmlRules, scxml, pr, 2);
         scxmlRules.add(XP_TR_TAR_ST, new SetNextRule("setTarget"));
 
         //// Parallels
@@ -308,22 +392,40 @@
 
     }
 
-    private static void addStateRules(String xp, ExtendedBaseRules scxmlRules,
-            SCXML scxml, PathResolver sc, int parent) {
+    /**
+     * Add Digester rules for all &lt;state&gt; elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param scxml The parent SCXML document (or null)
+     * @param pr The PathResolver
+     * @param parent The distance between this state and its parent
+     *               state on the Digester stack
+     */
+    private static void addStateRules(final String xp,
+            final ExtendedBaseRules scxmlRules, final SCXML scxml,
+            final PathResolver pr, final int parent) {
         scxmlRules.add(xp, new ObjectCreateRule(State.class));
-        addStatePropertiesRules(xp, scxmlRules, sc);
-        //scxmlRules.add(xp + XP_TAR, new SetPropertiesRule());
-        //scxmlRules.add(xp + XP_INI_TR_TAR, new SetPropertiesRule());
-        addInitialRule(xp + XP_INI, scxmlRules, sc, scxml);
-        addHistoryRules(xp + XP_HIST, scxmlRules, sc, scxml);
+        addStatePropertiesRules(xp, scxmlRules, pr);
+        addInitialRule(xp + XP_INI, scxmlRules, pr, scxml);
+        addHistoryRules(xp + XP_HIST, scxmlRules, pr, scxml);
         addParentRule(xp, scxmlRules, parent);
         addTransitionRules(xp + XP_TR, scxmlRules, "addTransition");
         addHandlerRules(xp, scxmlRules);
         scxmlRules.add(xp, new UpdateModelRule(scxml));
     }
 
-    private static void addParallelRules(String xp,
-            ExtendedBaseRules scxmlRules, SCXML scxml) {
+    /**
+     * Add Digester rules for all &lt;parallel&gt; elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param scxml The parent SCXML document (or null)
+     */
+    private static void addParallelRules(final String xp,
+            final ExtendedBaseRules scxmlRules, final SCXML scxml) {
         addSimpleRulesTuple(xp, scxmlRules, Parallel.class, null, null,
                 "setParallel");
         addHandlerRules(xp, scxmlRules);
@@ -331,51 +433,96 @@
         scxmlRules.add(xp, new UpdateModelRule(scxml));
     }
 
-    private static void addStatePropertiesRules(String xp,
-            ExtendedBaseRules scxmlRules, PathResolver sc) {
-        scxmlRules.add(xp, new SetPropertiesRule(
-                new String[] { "id", "final" },
-                new String[] { "id", "isFinal" }));
-        scxmlRules.add(xp, new DigestSrcAttributeRule(sc));
+    /**
+     * Add Digester rules for all &lt;state&gt; element attributes.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param pr The PathResolver
+     */
+    private static void addStatePropertiesRules(final String xp,
+            final ExtendedBaseRules scxmlRules, final PathResolver pr) {
+        scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id", "final"},
+            new String[] {"id", "isFinal"}));
+        scxmlRules.add(xp, new DigestSrcAttributeRule(pr));
     }
 
-    private static void addInitialRule(String xp,
-            ExtendedBaseRules scxmlRules, PathResolver sc, SCXML scxml) {
+    /**
+     * Add Digester rules for all &lt;initial&gt; elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param pr The PathResolver
+     * @param scxml The parent SCXML document (or null)
+     */
+    private static void addInitialRule(final String xp,
+            final ExtendedBaseRules scxmlRules, final PathResolver pr,
+            final SCXML scxml) {
         scxmlRules.add(xp, new ObjectCreateRule(Initial.class));
-        addPseudoStatePropertiesRules(xp, scxmlRules, sc);
+        addPseudoStatePropertiesRules(xp, scxmlRules, pr);
         scxmlRules.add(xp, new UpdateModelRule(scxml));
         addTransitionRules(xp + XP_TR, scxmlRules, "setTransition");
         scxmlRules.add(xp, new SetNextRule("setInitial"));
     }
-    
-    private static void addHistoryRules(String xp,
-            ExtendedBaseRules scxmlRules, PathResolver sc, SCXML scxml) {
+
+    /**
+     * Add Digester rules for all &lt;history&gt; elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param pr The PathResolver
+     * @param scxml The parent SCXML document (or null)
+     */
+    private static void addHistoryRules(final String xp,
+            final ExtendedBaseRules scxmlRules, final PathResolver pr,
+            final SCXML scxml) {
         scxmlRules.add(xp, new ObjectCreateRule(History.class));
-        addPseudoStatePropertiesRules(xp, scxmlRules, sc);
+        addPseudoStatePropertiesRules(xp, scxmlRules, pr);
         scxmlRules.add(xp, new UpdateModelRule(scxml));
-        scxmlRules.add(xp, new SetPropertiesRule(
-                new String[] { "type" }, new String[] { "type" }));
+        scxmlRules.add(xp, new SetPropertiesRule(new String[] {"type"},
+            new String[] {"type"}));
         addTransitionRules(xp + XP_TR, scxmlRules, "setTransition");
         scxmlRules.add(xp, new SetNextRule("addHistory"));
     }
-    
-    private static void addPseudoStatePropertiesRules(String xp,
-            ExtendedBaseRules scxmlRules, PathResolver sc) {
-        scxmlRules.add(xp, new SetPropertiesRule(
-            new String[] { "id" }, new String[] { "id" }));
-        scxmlRules.add(xp, new DigestSrcAttributeRule(sc));
+
+    /**
+     * Add Digester rules for all pseudo state (initial, history) element
+     * attributes.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param pr The PathResolver
+     */
+    private static void addPseudoStatePropertiesRules(final String xp,
+            final ExtendedBaseRules scxmlRules, final PathResolver pr) {
+        scxmlRules.add(xp, new SetPropertiesRule(new String[] {"id"},
+            new String[] {"id"}));
+        scxmlRules.add(xp, new DigestSrcAttributeRule(pr));
         addParentRule(xp, scxmlRules, 1);
     }
-    
-    private static void addParentRule(String xp, ExtendedBaseRules scxmlRules,
-            final int parent) {
+
+    /**
+     * Add Digester rule for all setting parent state.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param parent The distance between this state and its parent
+     *               state on the Digester stack
+     */
+    private static void addParentRule(final String xp,
+            final ExtendedBaseRules scxmlRules, final int parent) {
         if (parent < 1) {
             return;
         }
         scxmlRules.add(xp, new Rule() {
             // A generic version of setTopRule
-            public void body(String namespace, String name, String text)
-                    throws Exception {
+            public void body(final String namespace, final String name,
+                    final String text) throws Exception {
                 TransitionTarget t = (TransitionTarget) getDigester().peek();
                 TransitionTarget p = (TransitionTarget) getDigester().peek(
                         parent);
@@ -385,14 +532,23 @@
         });
     }
 
-    private static void addTransitionRules(String xp,
-            ExtendedBaseRules scxmlRules, String setNextMethod) {
+    /**
+     * Add Digester rules for all &lt;transition&gt; elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param setNextMethod The method name for adding this transition
+     *             to its parent (defined by the SCXML Java object model).
+     */
+    private static void addTransitionRules(final String xp,
+            final ExtendedBaseRules scxmlRules, final String setNextMethod) {
         scxmlRules.add(xp, new ObjectCreateRule(Transition.class));
         scxmlRules.add(xp, new SetPropertiesRule());
         scxmlRules.add(xp + XP_TAR, new SetPropertiesRule());
         addActionRules(xp, scxmlRules);
         scxmlRules.add(xp + XP_EXT, new Rule() {
-            public void end(String namespace, String name) {
+            public void end(final String namespace, final String name) {
                 Transition t = (Transition) getDigester().peek(1);
                 State exitState = new State();
                 exitState.setIsFinal(true);
@@ -402,7 +558,16 @@
         scxmlRules.add(xp, new SetNextRule(setNextMethod));
     }
 
-    private static void addHandlerRules(String xp, ExtendedBaseRules scxmlRules) {
+    /**
+     * Add Digester rules for all &lt;onentry&gt; and &lt;onexit&gt;
+     * elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     */
+    private static void addHandlerRules(final String xp,
+            final ExtendedBaseRules scxmlRules) {
         scxmlRules.add(xp + XP_ONEN, new ObjectCreateRule(OnEntry.class));
         addActionRules(xp + XP_ONEN, scxmlRules);
         scxmlRules.add(xp + XP_ONEN, new SetNextRule("setOnEntry"));
@@ -411,7 +576,15 @@
         scxmlRules.add(xp + XP_ONEX, new SetNextRule("setOnExit"));
     }
 
-    private static void addActionRules(String xp, ExtendedBaseRules scxmlRules) {
+    /**
+     * Add Digester rules for all actions (&quot;executable&quot; elements).
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     */
+    private static void addActionRules(final String xp,
+            final ExtendedBaseRules scxmlRules) {
         addActionRulesTuple(xp + XP_ASN, scxmlRules, Assign.class);
         addActionRulesTuple(xp + XP_VAR, scxmlRules, Var.class);
         addActionRulesTuple(xp + XP_LOG, scxmlRules, Log.class);
@@ -420,22 +593,52 @@
         addActionRulesTuple(xp + XP_EXT, scxmlRules, Exit.class);
     }
 
-    private static void addIfRules(String xp, ExtendedBaseRules scxmlRules) {
+    /**
+     * Add Digester rules for all &lt;if&gt; elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     */
+    private static void addIfRules(final String xp,
+            final ExtendedBaseRules scxmlRules) {
         addActionRulesTuple(xp, scxmlRules, If.class);
         addActionRules(xp, scxmlRules);
         addActionRulesTuple(xp + XP_EIF, scxmlRules, ElseIf.class);
         addActionRulesTuple(xp + XP_ELS, scxmlRules, Else.class);
     }
 
-    private static void addActionRulesTuple(String xp,
-            ExtendedBaseRules scxmlRules, Class klass) {
+    /**
+     * Add Digester rules that are common across all actions elements.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param klass The class in the Java object model to be instantiated
+     *              in the ObjectCreateRule for this action
+     */
+    private static void addActionRulesTuple(final String xp,
+            final ExtendedBaseRules scxmlRules, final Class klass) {
         addSimpleRulesTuple(xp, scxmlRules, klass, null, null, "addAction");
         scxmlRules.add(xp, new SetExecutableParentRule());
     }
 
-    private static void addSimpleRulesTuple(String xp,
-            ExtendedBaseRules scxmlRules, Class klass, String[] args,
-            String[] props, String addMethod) {
+    /**
+     * Add the run of the mill Digester rules for any element.
+     *
+     * @param xp The Digester style XPath expression of the parent
+     *           XML element
+     * @param scxmlRules The rule set to be used for digestion
+     * @param klass The class in the Java object model to be instantiated
+     *              in the ObjectCreateRule for this action
+     * @param args The attributes to be mapped into the object model
+     * @param props The properties that args get mapped to
+     * @param addMethod The method that the SetNextRule should call
+     */
+    private static void addSimpleRulesTuple(final String xp,
+            final ExtendedBaseRules scxmlRules, final Class klass,
+            final String[] args, final String[] props,
+            final String addMethod) {
         scxmlRules.add(xp, new ObjectCreateRule(klass));
         if (args == null) {
             scxmlRules.add(xp, new SetPropertiesRule());
@@ -446,10 +649,18 @@
     }
 
     /*
-     * Post-processing methods to make the SCXML object Executor-ready.
+     * Post-processing methods to make the SCXML object SCXMLExecutor ready.
      */
-    private static void updateSCXML(SCXML scxml, Context evalCtx,
-            Evaluator evalEngine) {
+     /**
+      * Update the SCXML object model (part of post-digestion processing).
+      *
+      * @param scxml The SCXML object (output from Digester)
+      * @param evalCtx The root evaluation context (from the host environment
+      *                of the SCXML document)
+      * @param evalEngine The expression evaluator
+      */
+    private static void updateSCXML(final SCXML scxml, final Context evalCtx,
+            final Evaluator evalEngine) {
         // Watch case, slightly unfortunate naming ;-)
         String initialstate = scxml.getInitialstate();
         //we have to use getTargets() here since the initialState can be
@@ -458,9 +669,7 @@
         State initialState = (State) scxml.getTargets().get(initialstate);
         if (initialState == null) {
             // Where do we, where do we go?
-            System.err.println("ERROR: SCXMLDigester - No SCXML child state "
-                    + "with ID \"" + initialstate
-                    + "\" found i.e. no initialstate" + " for SCXML ;-)");
+            logModelError(ERR_SCXML_NO_INIT, new Object[] {initialstate});
         }
         scxml.setInitialState(initialState);
         scxml.setRootContext(evalCtx);
@@ -473,8 +682,17 @@
         }
     }
 
-    private static void updateState(State s, Map targets, Context evalCtx,
-            Evaluator evalEngine) {
+    /**
+      * Update this State object (part of post-digestion processing).
+      * Also checks for any errors in the document.
+      *
+      * @param s The State object
+      * @param targets The global Map of all transition targets
+      * @param evalCtx The evaluation context for this State
+      * @param evalEngine The expression evaluator
+      */
+    private static void updateState(final State s, final Map targets,
+            final Context evalCtx, final Evaluator evalEngine) {
         //setup local variable context
         Context localCtx = null;
         if (s.getParent() == null) {
@@ -497,21 +715,22 @@
         //initialize next / inital
         Initial ini = s.getInitial();
         Map c = s.getChildren();
+        String badState = "anonymous state";
+        if (!SCXMLHelper.isStringEmpty(s.getId())) {
+            badState = "state with ID " + s.getId();
+        }
         if (!c.isEmpty()) {
             if (ini == null) {
-                System.err.println("WARNING: SCXMLDigester - Initial "
-                    + "null for " + (SCXMLHelper.isStringEmpty(s.getId()) ? 
-                    "anonymous state" : s.getId()));
+                logModelError(ERR_STATE_NO_INIT, new Object[] {badState});
             }
             Transition initialTransition = ini.getTransition();
             updateTransition(initialTransition, targets);
             TransitionTarget initialState = initialTransition.getTarget();
             // we have to allow for an indirect descendant initial (targets)
             //check that initialState is a descendant of s
-            if (initialState == null || !SCXMLHelper.isDescendant(initialState, s)) {
-                System.err.println("WARNING: SCXMLDigester - Initial state "
-                    + "null or not descendant for " + (SCXMLHelper.
-                    isStringEmpty(s.getId()) ? "anonymous state" : s.getId()));
+            if (initialState == null
+                    || !SCXMLHelper.isDescendant(initialState, s)) {
+                logModelError(ERR_STATE_BAD_INIT, new Object[] {badState});
             }
         }
         List histories = s.getHistory();
@@ -520,23 +739,19 @@
             History h = (History) histIter.next();
             Transition historyTransition = h.getTransition();
             updateTransition(historyTransition, targets);
-            State historyState = (State)historyTransition.getTarget();
+            State historyState = (State) historyTransition.getTarget();
             if (historyState == null) {
-                System.err.println("WARNING: SCXMLDigester - History state "
-                    + "null " + (SCXMLHelper.isStringEmpty(s.getId()) ? 
-                    "anonymous state" : s.getId()));
+                logModelError(ERR_STATE_NO_HIST, new Object[] {badState});
             }
             if (!h.isDeep()) {
                 if (!c.containsValue(historyState)) {
-                    System.err.println("WARNING: SCXMLDigester - History state "
-                        + "for shallow history is not child for " + (SCXMLHelper.
-                        isStringEmpty(s.getId()) ? "anonymous state" : s.getId()));                    
+                    logModelError(ERR_STATE_BAD_SHALLOW_HIST, new Object[] {
+                        badState });
                 }
             } else {
                 if (!SCXMLHelper.isDescendant(historyState, s)) {
-                    System.err.println("WARNING: SCXMLDigester - History state "
-                        + "for deep history is not descendant for " + (SCXMLHelper.
-                        isStringEmpty(s.getId()) ? "anonymous state" : s.getId()));
+                    logModelError(ERR_STATE_BAD_DEEP_HIST, new Object[] {
+                        badState });
                 }
             }
         }
@@ -565,15 +780,30 @@
         }
     }
 
-    private static void updateParallel(Parallel p, Map targets,
-            Context evalCtx, Evaluator evalEngine) {
+    /**
+      * Update this Parallel object (part of post-digestion processing).
+      *
+      * @param p The Parallel object
+      * @param targets The global Map of all transition targets
+      * @param evalCtx The evaluation context for this State
+      * @param evalEngine The expression evaluator
+      */
+    private static void updateParallel(final Parallel p, final Map targets,
+            final Context evalCtx, final Evaluator evalEngine) {
         Iterator i = p.getStates().iterator();
         while (i.hasNext()) {
             updateState((State) i.next(), targets, evalCtx, evalEngine);
         }
     }
 
-    private static void updateTransition(Transition t, Map targets) {
+    /**
+      * Update this Transition object (part of post-digestion processing).
+      *
+      * @param t The Transition object
+      * @param targets The global Map of all transition targets
+      */
+    private static void updateTransition(final Transition t,
+            final Map targets) {
         String next = t.getNext();
         TransitionTarget tt = t.getTarget();
         if (tt == null) {
@@ -587,10 +817,31 @@
         }
     }
 
+    /**
+      * Log an error discovered in post-digestion processing.
+      *
+      * @param errType The type of error
+      * @param msgArgs The arguments for formatting the error message
+      */
+    private static void logModelError(final String errType,
+            final Object[] msgArgs) {
+        MessageFormat msgFormat = new MessageFormat(errType);
+        String errMsg = msgFormat.format(msgArgs);
+        log.error(errMsg);
+    }
+
     /*
-     * Private SCXML object serialization utility functions
+     * Private SCXML object serialization utility functions.
      */
-    private static void serializeState(StringBuffer b, State s, String indent) {
+    /**
+     * Serialize this State object.
+     *
+     * @param b The buffer to append the serialization to
+     * @param s The State to serialize
+     * @param indent The indent for this XML element
+     */
+    private static void serializeState(final StringBuffer b,
+            final State s, final String indent) {
         b.append(indent).append("<state");
         serializeTransitionTargetAttributes(b, s);
         boolean f = s.getIsFinal();
@@ -631,8 +882,15 @@
         b.append(indent).append("</state>\n");
     }
 
-    private static void serializeParallel(StringBuffer b, Parallel p,
-            String indent) {
+    /**
+     * Serialize this Parallel object.
+     *
+     * @param b The buffer to append the serialization to
+     * @param p The Parallel to serialize
+     * @param indent The indent for this XML element
+     */
+    private static void serializeParallel(final StringBuffer b,
+            final Parallel p, final String indent) {
         b.append(indent).append("<parallel");
         serializeTransitionTargetAttributes(b, p);
         b.append(">\n");
@@ -645,24 +903,38 @@
         serializeOnExit(b, (TransitionTarget) p, indent + INDENT);
         b.append(indent).append("</parallel>\n");
     }
-    
-    private static void serializeInitial(StringBuffer b, Initial i,
-            String indent) {
+
+    /**
+     * Serialize this Initial object.
+     *
+     * @param b The buffer to append the serialization to
+     * @param i The Initial to serialize
+     * @param indent The indent for this XML element
+     */
+    private static void serializeInitial(final StringBuffer b, final Initial i,
+            final String indent) {
         b.append(indent).append("<initial");
         serializeTransitionTargetAttributes(b, i);
         b.append(">\n");
         serializeTransition(b, i.getTransition(), indent + INDENT);
         b.append(indent).append("</initial>\n");
     }
-    
-    private static void serializeHistory(StringBuffer b, List l,
-            String indent) {
+
+    /**
+     * Serialize the History.
+     *
+     * @param b The buffer to append the serialization to
+     * @param l The List of History objects to serialize
+     * @param indent The indent for this XML element
+     */
+    private static void serializeHistory(final StringBuffer b, final List l,
+            final String indent) {
         if (l.size() > 0) {
             for (int i = 0; i < l.size(); i++) {
                 History h = (History) l.get(i);
                 b.append(indent).append("<history");
                 serializeTransitionTargetAttributes(b, h);
-                 if(h.isDeep()) {
+                 if (h.isDeep()) {
                      b.append(" type=\"deep\"");
                  } else {
                      b.append(" type=\"shallow\"");
@@ -674,8 +946,14 @@
         }
     }
 
-    private static void serializeTransitionTargetAttributes(StringBuffer b,
-            TransitionTarget t) {
+    /**
+     * Serialize properties of TransitionTarget which are element attributes.
+     *
+     * @param b The buffer to append the serialization to
+     * @param t The TransitionTarget
+     */
+    private static void serializeTransitionTargetAttributes(
+            final StringBuffer b, final TransitionTarget t) {
         String id = t.getId();
         if (id != null) {
             b.append(" id=\"" + id + "\"");
@@ -689,8 +967,15 @@
         }
     }
 
-    private static void serializeTransition(StringBuffer b, Transition t,
-            String indent) {
+    /**
+     * Serialize this Transition object.
+     *
+     * @param b The buffer to append the serialization to
+     * @param t The Transition to serialize
+     * @param indent The indent for this XML element
+     */
+    private static void serializeTransition(final StringBuffer b,
+            final Transition t, final String indent) {
         b.append(indent).append("<transition event=\"").append(t.getEvent())
                 .append("\" cond=\"").append(t.getCond()).append("\">\n");
         boolean exit = serializeActions(b, t.getActions(), indent + INDENT);
@@ -700,8 +985,16 @@
         b.append(indent).append("</transition>\n");
     }
 
-    private static void serializeTarget(StringBuffer b, Transition t,
-            String indent) {
+    /**
+     * Serialize this Transition's Target.
+     *
+     *
+     * @param b The buffer to append the serialization to
+     * @param t The Transition whose Target needs to be serialized
+     * @param indent The indent for this XML element
+     */
+    private static void serializeTarget(final StringBuffer b,
+            final Transition t, final String indent) {
         b.append(indent).append("<target");
         String n = t.getNext();
         if (n != null) {
@@ -716,8 +1009,15 @@
         b.append(indent).append("</target>\n");
     }
 
-    private static void serializeOnEntry(StringBuffer b, TransitionTarget t,
-            String indent) {
+    /**
+     * Serialize this OnEntry object.
+     *
+     * @param b The buffer to append the serialization to
+     * @param t The TransitionTarget whose OnEntry is to be serialized
+     * @param indent The indent for this XML element
+     */
+    private static void serializeOnEntry(final StringBuffer b,
+            final TransitionTarget t, final String indent) {
         OnEntry e = t.getOnEntry();
         if (e != null && e.getActions().size() > 0) {
             b.append(indent).append("<onentry>\n");
@@ -726,8 +1026,15 @@
         }
     }
 
-    private static void serializeOnExit(StringBuffer b, TransitionTarget t,
-            String indent) {
+    /**
+     * Serialize this OnExit object.
+     *
+     * @param b The buffer to append the serialization to
+     * @param t The TransitionTarget whose OnExit is to be serialized
+     * @param indent The indent for this XML element
+     */
+    private static void serializeOnExit(final StringBuffer b,
+            final TransitionTarget t, final String indent) {
         OnExit x = t.getOnExit();
         if (x != null && x.getActions().size() > 0) {
             b.append(indent).append("<onexit>\n");
@@ -736,8 +1043,16 @@
         }
     }
 
-    private static boolean serializeActions(StringBuffer b, List l,
-            String indent) {
+    /**
+     * Serialize this List of actions.
+     *
+     * @param b The buffer to append the serialization to
+     * @param l The List of actions to serialize
+     * @param indent The indent for this XML element
+     * @return boolean true if the list of actions contains an &lt;exit/&gt;
+     */
+    private static boolean serializeActions(final StringBuffer b, final List l,
+            final String indent) {
         if (l == null) {
             return false;
         }
@@ -780,8 +1095,8 @@
                 b.append("/>\n");
                 exit = true;
             } else if (a instanceof If) {
-                If IF = (If) a;
-                serializeIf(b, IF, indent);
+                If iff = (If) a;
+                serializeIf(b, iff, indent);
             } else if (a instanceof Else) {
                 Else el = (Else) a;
                 b.append(indent).append("<else/>\n");
@@ -794,30 +1109,56 @@
         return exit;
     }
 
-    private static void serializeIf(StringBuffer b, If IF, String indent) {
-        b.append(indent).append("<if cond=\"").append(IF.getCond()).append(
+    /**
+     * Serialize this If object.
+     *
+     * @param b The buffer to append the serialization to
+     * @param iff The If object to serialize
+     * @param indent The indent for this XML element
+     */
+    private static void serializeIf(final StringBuffer b,
+            final If iff, final String indent) {
+        b.append(indent).append("<if cond=\"").append(iff.getCond()).append(
                 "\">\n");
-        serializeActions(b, IF.getActions(), indent + INDENT);
+        serializeActions(b, iff.getActions(), indent + INDENT);
         b.append(indent).append("</if>\n");
     }
 
     /**
-     * Custom digestion rule for establishing necessary associations within the
-     * SCXML object, which include: <br>
+     * Discourage instantiation since this is a utility class.
+     */
+    private SCXMLDigester() {
+        super();
+    }
+
+    /**
+     * Custom digestion rule for establishing necessary associations of this
+     * TransitionTarget with the root SCXML object.
+     * These include: <br>
      * 1) Updation of the SCXML object's global targets Map <br>
      * 2) Obtaining a handle to the SCXML object's NotificationRegistry <br>
-     * 
+     *
      */
     public static class UpdateModelRule extends Rule {
 
+        /**
+         * The root SCXML object.
+         */
         private SCXML scxml;
 
-        public UpdateModelRule(SCXML scxml) {
+        /**
+         * Constructor.
+         * @param scxml The root SCXML object
+         */
+        public UpdateModelRule(final SCXML scxml) {
             super();
             this.scxml = scxml;
         }
 
-        public void end(String namespace, String name) {
+        /**
+         * @see Rule#end(String, String)
+         */
+        public final void end(final String namespace, final String name) {
             if (scxml == null) {
                 scxml = (SCXML) getDigester()
                         .peek(getDigester().getCount() - 1);
@@ -830,16 +1171,22 @@
     }
 
     /**
-     * Custom digestion rule for setting Executable parent of Action elements
-     * 
+     * Custom digestion rule for setting Executable parent of Action elements.
+     *
      */
     public static class SetExecutableParentRule extends Rule {
 
+        /**
+         * Constructor.
+         */
         public SetExecutableParentRule() {
             super();
         }
 
-        public void end(String namespace, String name) {
+        /**
+         * @see Rule#end(String, String)
+         */
+        public final void end(final String namespace, final String name) {
             Action child = (Action) getDigester().peek();
             for (int i = 1; i < getDigester().getCount() - 1; i++) {
                 Object ancestor = (Object) getDigester().peek(i);
@@ -853,19 +1200,33 @@
 
     /**
      * Custom digestion rule for external sources, that is, the src attribute of
-     * the &lt;state&gt; element
-     * 
+     * the &lt;state&gt; element.
+     *
      */
     public static class DigestSrcAttributeRule extends Rule {
 
-        private PathResolver ctx;
-
-        public DigestSrcAttributeRule(PathResolver sc) {
+        /**
+         * The PathResolver used to resolve the src attribute to the
+         * SCXML document it points to.
+         * @see PathResolver
+         */
+        private PathResolver pr;
+
+        /**
+         * Constructor.
+         * @param pr The PathResolver
+         * @see PathResolver
+         */
+        public DigestSrcAttributeRule(final PathResolver pr) {
             super();
-            this.ctx = sc;
+            this.pr = pr;
         }
 
-        public void begin(String namespace, String name, Attributes attributes) {
+        /**
+         * @see Rule#begin(String, String, Attributes)
+         */
+        public final void begin(final String namespace, final String name,
+                final Attributes attributes) {
             String src = attributes.getValue("src");
             if (SCXMLHelper.isStringEmpty(src)) {
                 return;
@@ -873,9 +1234,15 @@
             Digester digester = getDigester();
             SCXML scxml = (SCXML) digester.peek(digester.getCount() - 1);
             // 1) Digest the external SCXML file
-            Digester externalSrcDigester = newInstance(scxml, ctx.getResolver(src));
+            Digester externalSrcDigester = newInstance(scxml,
+                pr.getResolver(src));
             SCXML externalSCXML = null;
-            String path = ctx == null ? src : ctx.resolvePath(src);
+            String path = null;
+            if (pr == null) {
+                path = src;
+            } else {
+                path = pr.resolvePath(src);
+            }
 
             try {
                 externalSCXML = (SCXML) externalSrcDigester.parse(path);
@@ -901,3 +1268,4 @@
         }
     }
 }
+

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExecutor.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -29,28 +29,31 @@
 import org.apache.commons.scxml.model.TransitionTarget;
 
 /**
- * The SCXML &quot;engine&quot; that executes SCXML documents. The 
- * particular semantics used by this engine for executing the SCXML are 
+ * The SCXML &quot;engine&quot; that executes SCXML documents. The
+ * particular semantics used by this engine for executing the SCXML are
  * encapsulated in SCXMLSemantics.
- * 
+ *
  * @see SCXMLSemantics
  */
 public class SCXMLExecutor {
-    
+
+    /**
+     * The Logger for the SCXMLExecutor.
+     */
     private static Log log = LogFactory.getLog(SCXMLExecutor.class);
-    
+
     /**
-     * The stateMachine being executed
+     * The stateMachine being executed.
      */
     private SCXML stateMachine;
 
     /**
-     * The evaluator for expressions
+     * The evaluator for expressions.
      */
     private Evaluator evaluator;
 
     /**
-     * The current status of the stateMachine
+     * The current status of the stateMachine.
      */
     private Status currentStatus;
 
@@ -60,33 +63,33 @@
     private EventDispatcher eventdispatcher;
 
     /**
-     * The environment specific error reporter
+     * The environment specific error reporter.
      */
     private ErrorReporter errorReporter = null;
-    
-    /** 
-     * Run-to-completion
+
+    /**
+     * Run-to-completion.
      */
     private boolean superStep = true;
-    
-    /** 
-     *  Interpretation semantics 
+
+    /**
+     *  Interpretation semantics.
      *  (not configurable without re-compilation for now,
      *   since we have one implementation anyway)
      */
     private SCXMLSemantics semantics = new SCXMLSemantics();
-    
+
     /**
-     * The worker method. Re-evaluates current status whenever any events
-     * are triggered.
-     * 
+     * The worker method.
+     * Re-evaluates current status whenever any events are triggered.
+     *
      * @param evts
      *            an array of external events which triggered during the last
      *            time quantum
-     * @throws ModelException in case there is a fatal SCXML object 
-     *  model problem.
+     * @throws ModelException in case there is a fatal SCXML object
+     *            model problem.
      */
-    public void triggerEvents(TriggerEvent evts[])
+    public void triggerEvents(final TriggerEvent[] evts)
             throws ModelException {
         ArrayList evs = new ArrayList(Arrays.asList(evts));
         do {
@@ -111,67 +114,67 @@
             // AssignCurrentStatus
             updateStatus(step);
             // ***Cleanup external events if superStep
-            if(superStep) {
+            if (superStep) {
                 evs.clear();
             }
         } while(superStep && currentStatus.getEvents().size() > 0);
         logState();
     }
 
-    public SCXMLExecutor() throws ModelException {
-        this(null, null, null);
-    }
-
     /**
-     * Constructor
-     * 
-     * @param stateMachine The stateMachine to execute
-     * @param evaluator The expression evaluator
+     * Constructor.
+     *
+     * @param expEvaluator The expression evaluator
      * @param evtDisp The event dispatcher
      * @param errRep The error reporter
-     * @throws ModelException in case there is a fatal SCXML object 
-     *  model problem.
      */
-    public SCXMLExecutor(Evaluator evaluator, EventDispatcher evtDisp,
-            ErrorReporter errRep) throws ModelException {
-        this.evaluator = evaluator;
+    public SCXMLExecutor(final Evaluator expEvaluator,
+            final EventDispatcher evtDisp, final ErrorReporter errRep) {
+        this.evaluator = expEvaluator;
         this.eventdispatcher = evtDisp;
         this.errorReporter = errRep;
         this.currentStatus = null;
         this.stateMachine = null;
     }
-    
+
+    /**
+     * Convenience constructor.
+     */
+    public SCXMLExecutor() {
+        this(null, null, null);
+    }
+
     /**
      * Clear all state and begin from &quot;initialstate&quot; indicated
      * on root SCXML element.
-     * 
-     * @throws ModelException in case there is a fatal SCXML object 
-     *  model problem. 
+     *
+     * @throws ModelException in case there is a fatal SCXML object
+     *         model problem.
      */
     public void reset() throws ModelException {
         // Reset all variable contexts
         stateMachine.getRootContext().reset();
         // all states and parallels, only states have var. contexts
-        for (Iterator i = stateMachine.getTargets().values().iterator(); 
+        for (Iterator i = stateMachine.getTargets().values().iterator();
                 i.hasNext();) {
-            TransitionTarget tt = (TransitionTarget)i.next();
-            if(tt instanceof State) {
-                ((State)tt).getContext().reset();
+            TransitionTarget tt = (TransitionTarget) i.next();
+            if (tt instanceof State) {
+                ((State) tt).getContext().reset();
             }
         }
         // CreateEmptyStatus
         currentStatus = new Status();
         Step step = new Step(null, currentStatus);
         // DetermineInitialStates
-        semantics.determineInitialStates(stateMachine, 
-                step.getAfterStatus().getStates(), 
+        semantics.determineInitialStates(stateMachine,
+                step.getAfterStatus().getStates(),
                 step.getEntryList(), errorReporter);
         // ExecuteActions
         semantics.executeActions(step, this, errorReporter);
         // AssignCurrentStatus
         updateStatus(step);
         // Execute Immediate Transitions
-        if(superStep && currentStatus.getEvents().size() > 0) {
+        if (superStep && currentStatus.getEvents().size() > 0) {
             this.triggerEvents(new TriggerEvent[0]);
         } else {
             logState();
@@ -179,8 +182,8 @@
     }
 
     /**
-     * Get the current status
-     * 
+     * Get the current status.
+     *
      * @return The current Status
      */
     public Status getCurrentStatus() {
@@ -188,114 +191,121 @@
     }
 
     /**
-     * Get the expression evaluator
-     * 
+     * Get the expression evaluator.
+     *
      * @return Returns the evaluator.
      */
     public Evaluator getEvaluator() {
         return evaluator;
     }
-    
+
     /**
      * @param evaluator The evaluator to set.
      */
-    public void setEvaluator(Evaluator evaluator) {
+    public void setEvaluator(final Evaluator evaluator) {
         this.evaluator = evaluator;
     }
-    
+
     /**
-     * Get the state machine that is being executed
-     * 
+     * Get the state machine that is being executed.
+     *
      * @return Returns the stateMachine.
      */
     public SCXML getStateMachine() {
         return stateMachine;
     }
-    
+
     /**
-     * Set the state machine to be executed
-     * 
+     * Set the state machine to be executed.
+     *
      * @param stateMachine The stateMachine to set.
      * @throws ModelException in case there is a fatal SCXML object
      *  model problem.
      */
-    public void setStateMachine(SCXML statemachine) throws ModelException {
+    public void setStateMachine(final SCXML stateMachine)
+            throws ModelException {
         // NormalizeStateMachine
-        SCXML sm = semantics.normalizeStateMachine(statemachine,
+        SCXML sm = semantics.normalizeStateMachine(stateMachine,
                 errorReporter);
         // StoreStateMachine
         this.stateMachine = sm;
         // reset
         this.reset();
     }
-    
+
     /**
-     * Get the environment specific error reporter
-     * 
+     * Get the environment specific error reporter.
+     *
      * @return Returns the errorReporter.
      */
     public ErrorReporter getErrorReporter() {
         return errorReporter;
     }
-    
+
     /**
-     * Set the environment specific error reporter
-     * 
+     * Set the environment specific error reporter.
+     *
      * @param errorReporter The errorReporter to set.
      */
-    public void setErrorReporter(ErrorReporter errorReporter) {
+    public void setErrorReporter(final ErrorReporter errorReporter) {
         this.errorReporter = errorReporter;
     }
-    
+
     /**
-     * Get the event dispatcher
-     * 
+     * Get the event dispatcher.
+     *
      * @return Returns the eventdispatcher.
      */
     public EventDispatcher getEventdispatcher() {
         return eventdispatcher;
     }
-    
+
     /**
-     * Set the event dispatcher
-     * 
+     * Set the event dispatcher.
+     *
      * @param eventdispatcher The eventdispatcher to set.
      */
-    public void setEventdispatcher(EventDispatcher eventdispatcher) {
+    public void setEventdispatcher(final EventDispatcher eventdispatcher) {
         this.eventdispatcher = eventdispatcher;
     }
-    
+
     /**
-     * Use &quot;super-step&quot;, default is <code>true</code> 
-     * (that is, run-to-completion is default)
+     * Use &quot;super-step&quot;, default is <code>true</code>
+     * (that is, run-to-completion is default).
+     *
      * @return Returns the superStep property.
      * @see #setSuperStep(boolean)
      */
     public boolean isSuperStep() {
         return superStep;
     }
-    
+
     /**
-     * Set the super step
+     * Set the super step.
+     *
      * @param superStep
-     * if true, the internal derived events are also processed (run-to-completion); 
+     * if true, the internal derived events are also processed
+     *    (run-to-completion);
      * if false, the internal derived events are stored in the
      * CurrentStatus property and processed within the next
-     * triggerEvents() invocation, also the immediate (empty event) transitions 
+     * triggerEvents() invocation, also the immediate (empty event) transitions
      * are deferred until the next step
       */
-    public void setSuperStep(boolean superStep) {
+    public void setSuperStep(final boolean superStep) {
         this.superStep = superStep;
     }
-    
+
+    /**
+     * Log the current set of active states.
+     */
     private void logState() {
-        if(log.isInfoEnabled()) {
+        if (log.isInfoEnabled()) {
             Iterator si = currentStatus.getStates().iterator();
             StringBuffer sb = new StringBuffer("Current States: [");
-            while(si.hasNext()) {
-                State s = (State)si.next();
+            while (si.hasNext()) {
+                State s = (State) si.next();
                 sb.append(s.getId());
-                if(si.hasNext()) {
+                if (si.hasNext()) {
                     sb.append(", ");
                 }
             }
@@ -305,11 +315,11 @@
     }
 
     /**
-     * @param step
+     * @param step The most recent Step
      */
-    private void updateStatus(Step step) {
+    private void updateStatus(final Step step) {
         this.currentStatus = step.getAfterStatus();
         stateMachine.getRootContext().setLocal("_ALL_STATES",
-                SCXMLHelper.getAncestorClosure(currentStatus.getStates(), null));
+            SCXMLHelper.getAncestorClosure(currentStatus.getStates(), null));
     }
-}
\ No newline at end of file
+}

Modified: jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExpressionException.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExpressionException.java?rev=234141&r1=234140&r2=234141&view=diff
==============================================================================
--- jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExpressionException.java (original)
+++ jakarta/commons/sandbox/scxml/trunk/src/main/java/org/apache/commons/scxml/SCXMLExpressionException.java Sat Aug 20 20:24:20 2005
@@ -1,6 +1,6 @@
 /*
- *    
- *   Copyright 2004 The Apache Software Foundation.
+ *
+ *   Copyright 2005 The Apache Software Foundation.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 /**
  * Exception thrown when a malformed expression is encountered during
  * evaluation of an expression in a SCXML document.
- * 
+ *
  */
 public class SCXMLExpressionException extends Exception {
 
@@ -33,27 +33,29 @@
 
     /**
      * @see java.lang.Exception#Exception(java.lang.String)
-     * @param message
+     * @param message The error message
      */
-    public SCXMLExpressionException(String message) {
+    public SCXMLExpressionException(final String message) {
         super(message);
     }
 
     /**
      * @see java.lang.Exception#Exception(java.lang.Throwable)
-     * @param cause
+     * @param cause The cause
      */
-    public SCXMLExpressionException(Throwable cause) {
+    public SCXMLExpressionException(final Throwable cause) {
         super(cause);
     }
-    
+
     /**
-     * @see java.lang.Exception#Exception(java.lang.String, java.lang.Throwable)
-     * @param message
-     * @param cause
+     * @see java.lang.Exception#Exception(String, Throwable)
+     * @param message The error message
+     * @param cause The cause
      */
-    public SCXMLExpressionException(String message, Throwable cause) {
+    public SCXMLExpressionException(final String message,
+            final Throwable cause) {
         super(message, cause);
     }
 
 }
+



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org