Coverage Report - org.apache.commons.workflow.core.GetStep
 
Classes in this File Line Coverage Branch Coverage Complexity
GetStep
0%
0/16
0%
0/4
1.75
 
 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 org.apache.commons.workflow.Context;
 21  
 import org.apache.commons.workflow.Descriptor;
 22  
 import org.apache.commons.workflow.StepException;
 23  
 import org.apache.commons.workflow.base.DescriptorStep;
 24  
 
 25  
 
 26  
 /**
 27  
  * <p>For each associated <code>Descriptor</code>, make a copy of the
 28  
  * specified Java object and push it on to the evaluation stack, in the
 29  
  * order that descriptors are listed.</p>
 30  
  *
 31  
  * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
 32  
  * @author Craig R. McClanahan
 33  
  */
 34  
 
 35  
 public class GetStep extends DescriptorStep {
 36  
 
 37  
 
 38  
     // ----------------------------------------------------------= Constructors
 39  
 
 40  
 
 41  
     /**
 42  
      * Construct a default instance of this Step.
 43  
      */
 44  
     public GetStep() {
 45  
 
 46  0
         super();
 47  
 
 48  0
     }
 49  
 
 50  
 
 51  
     /**
 52  
      * Construct an instance of this Step with the specified identifier.
 53  
      *
 54  
      * @param id Step identifier
 55  
      */
 56  
     public GetStep(String id) {
 57  
 
 58  0
         super();
 59  0
         setId(id);
 60  
 
 61  0
     }
 62  
 
 63  
 
 64  
     /**
 65  
      * Construct an instance of this Step with the specified identifier
 66  
      * and associated Descriptor.
 67  
      *
 68  
      * @param id Step identifier
 69  
      * @param descriptor Initial descriptor
 70  
      */
 71  
     public GetStep(String id, Descriptor descriptor) {
 72  
 
 73  0
         super();
 74  0
         setId(id);
 75  0
         addDescriptor(descriptor);
 76  
 
 77  0
     }
 78  
 
 79  
 
 80  
     // --------------------------------------------------------- Public Methods
 81  
 
 82  
 
 83  
     /**
 84  
      * Perform the executable actions related to this Step, in the context of
 85  
      * the specified Context.
 86  
      *
 87  
      * @param context The Context that is tracking our execution state
 88  
      *
 89  
      * @exception StepException if a processing error has occurred
 90  
      */
 91  
     public void execute(Context context) throws StepException {
 92  
 
 93  
         // Process all associated descriptors
 94  0
         Descriptor descriptors[] = findDescriptors();
 95  0
         for (int i = 0; i < descriptors.length; i++) {
 96  0
             Object value = descriptors[i].get(context);
 97  0
             if (value == null)
 98  0
                 throw new StepException
 99  
                     ("Cannot retrieve object for " + descriptors[i], this);
 100  0
             context.push(value);
 101  
         }
 102  
 
 103  0
     }
 104  
 
 105  
 
 106  
 }