01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.apache.commons.chain.generic;
17:
18: import org.apache.commons.chain.Command;
19: import org.apache.commons.chain.Context;
20:
21: /**
22: * <p>Remove any context attribute stored under the <code>fromKey</code>.</p>
23: *
24: * @author Craig R. McClanahan
25: * @version $Revision: 410386 $ $Date: 2006-05-30 22:48:31 +0100 (Tue, 30 May 2006) $
26: */
27:
28: public class RemoveCommand implements Command {
29:
30: // -------------------------------------------------------------- Properties
31:
32: private String fromKey = null;
33:
34: /**
35: * <p>Return the context attribute key for the attribute.</p>
36: * @return The context attribute key.
37: */
38: public String getFromKey() {
39:
40: return (this .fromKey);
41:
42: }
43:
44: /**
45: * <p>Set the context attribute key for the attribute.</p>
46: *
47: * @param fromKey The new key
48: */
49: public void setFromKey(String fromKey) {
50:
51: this .fromKey = fromKey;
52:
53: }
54:
55: // ---------------------------------------------------------- Filter Methods
56:
57: /**
58: * <p>Copy the specified source attribute to the specified destination
59: * attribute.</p>
60: *
61: * @param context {@link Context} in which we are operating
62: *
63: * @return <code>false</code> so that processing will continue
64: * @throws Exception if and error occurs.
65: */
66: public boolean execute(Context context) throws Exception {
67:
68: context.remove(getFromKey());
69: return (false);
70:
71: }
72:
73: }
|