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.Context;
22 import org.apache.commons.workflow.StepException;
23 import org.apache.commons.workflow.base.BaseStep;
24
25
26 /**
27 * <p>Pop the top value from the evaluation stack and throw it away.</p>
28 *
29 * @version $Revision: 155475 $ $Date: 2005-02-26 13:31:11 +0000 (Sat, 26 Feb 2005) $
30 * @author Craig R. McClanahan
31 */
32
33 public class PopStep extends BaseStep {
34
35
36 // ----------------------------------------------------------= Constructors
37
38
39 /**
40 * Construct a default instance of this Step.
41 */
42 public PopStep() {
43
44 super();
45
46 }
47
48
49 /**
50 * Construct an instance of this Step with the specified identifier.
51 *
52 * @param id Step identifier
53 */
54 public PopStep(String id) {
55
56 super();
57 setId(id);
58
59 }
60
61
62 // --------------------------------------------------------- Public Methods
63
64
65 /**
66 * Perform the executable actions related to this Step, in the context of
67 * the specified Context.
68 *
69 * @param context The Context that is tracking our execution state
70 *
71 * @exception StepException if a processing error has occurred
72 */
73 public void execute(Context context) throws StepException {
74
75 // Pop the evaluation stack
76 Object value = null;
77 try {
78 value = context.pop();
79 } catch (EmptyStackException e) {
80 throw new StepException("Evaluation stack is empty", e, this);
81 }
82
83 }
84
85
86 }