Coverage Report - org.apache.commons.workflow.core.CallStep
 
Classes in this File Line Coverage Branch Coverage Complexity
CallStep
0%
0/14
0%
0/2
2.333
 
 1  
 /*
 2  
  * Copyright 1999-2001,2004 The Apache Software Foundation.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */ 
 16  
 
 17  
 package org.apache.commons.workflow.core;
 18  
 
 19  
 
 20  
 import java.util.EmptyStackException;
 21  
 import org.apache.commons.workflow.Activity;
 22  
 import org.apache.commons.workflow.Context;
 23  
 import org.apache.commons.workflow.StepException;
 24  
 import org.apache.commons.workflow.base.BaseStep;
 25  
 
 26  
 
 27  
 /**
 28  
  * <p>Pop the top value from the evaluation stack, which must be an
 29  
  * <code>Activity</code>, and initiate a "subroutine call" to execute
 30  
  * this Activity before resuming the current one.</p>
 31  
  *
 32  
  * <p><strong>NOTE</strong> - The means by which the Activity on the top
 33  
  * of the stack was acquired is NOT mandated by this Step implementation.</p>
 34  
  *
 35  
  * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
 36  
  * @author Craig R. McClanahan
 37  
  */
 38  
 
 39  
 public class CallStep extends BaseStep {
 40  
 
 41  
 
 42  
     // ----------------------------------------------------------= Constructors
 43  
 
 44  
 
 45  
     /**
 46  
      * Construct a default instance of this Step.
 47  
      */
 48  
     public CallStep() {
 49  
 
 50  0
         super();
 51  
 
 52  0
     }
 53  
 
 54  
 
 55  
     /**
 56  
      * Construct an instance of this Step with the specified identifier.
 57  
      *
 58  
      * @param id Step identifier
 59  
      */
 60  
     public CallStep(String id) {
 61  
 
 62  0
         super();
 63  0
         setId(id);
 64  
 
 65  0
     }
 66  
 
 67  
 
 68  
     // --------------------------------------------------------- Public Methods
 69  
 
 70  
 
 71  
     /**
 72  
      * Perform the executable actions related to this Step, in the context of
 73  
      * the specified Context.
 74  
      *
 75  
      * @param context The Context that is tracking our execution state
 76  
      *
 77  
      * @exception StepException if a processing error has occurred
 78  
      */
 79  
     public void execute(Context context) throws StepException {
 80  
 
 81  
         // Pop the evaluation stack
 82  0
         Object value = null;
 83  
         try {
 84  0
             value = context.pop();
 85  0
         } catch (EmptyStackException e) {
 86  0
             throw new StepException("Evaluation stack is empty", e, this);
 87  0
         }
 88  
 
 89  
         // Call the requested Activity 
 90  0
         if (!(value instanceof Activity))
 91  0
             throw new StepException("Top of stack is not an Activity", this);
 92  0
         context.call((Activity) value);
 93  
 
 94  0
     }
 95  
 
 96  
 
 97  
 }