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