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.base; 18 19 20 import java.util.ArrayList; 21 import org.apache.commons.workflow.Activity; 22 import org.apache.commons.workflow.Context; 23 import org.apache.commons.workflow.Descriptor; 24 import org.apache.commons.workflow.Descriptors; 25 import org.apache.commons.workflow.Step; 26 import org.apache.commons.workflow.StepException; 27 28 29 /** 30 * <p><strong>DescriptorStep</strong> is a convenient base class for more 31 * sophisticated <code>Step</code> implementations that already support 32 * the APIs provided by <code>BaseStep</code>, and also implement the 33 * <code>Descriptors</code> interafce. 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 abstract class DescriptorStep extends BaseStep implements Descriptors { 40 41 42 // ----------------------------------------------------- Instance Variables 43 44 45 /** 46 * The list of <code>Descriptor</code> objects associated with this 47 * <code>Step</code>. 48 */ 49 protected ArrayList descriptors = new ArrayList(); 50 51 52 // --------------------------------------------------------- Public Methods 53 54 55 /** 56 * Add a new <code>Descriptor</code> to the set associated with 57 * this object. 58 * 59 * @param descriptor The Descriptor to be added 60 */ 61 public void addDescriptor(Descriptor descriptor) { 62 63 descriptors.add(descriptor); 64 65 } 66 67 68 /** 69 * Return the set of <code>Descriptor</code> objects associated with 70 * this object, in the order that they were originally added. 71 */ 72 public Descriptor[] findDescriptors() { 73 74 Descriptor results[] = new Descriptor[descriptors.size()]; 75 return ((Descriptor[]) descriptors.toArray(results)); 76 77 } 78 79 80 /** 81 * Remove an existing <code>Descriptor</code> from the set associated 82 * with this object. 83 * 84 * @param descriptor The Descriptor to be removed 85 */ 86 public void removeDescriptor(Descriptor descriptor) { 87 88 descriptors.remove(descriptor); 89 90 } 91 92 93 }