View Javadoc

1   /*
2    * Copyright 1999-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  package org.apache.commons.chain.generic;
17  
18  
19  import org.apache.commons.chain.Command;
20  import org.apache.commons.chain.Context;
21  
22  
23  /***
24   * <p>Remove any context attribute stored under the <code>fromKey</code>.</p>
25   *
26   * @author Craig R. McClanahan
27   * @version $Revision: 410386 $ $Date: 2006-05-30 22:48:31 +0100 (Tue, 30 May 2006) $
28   */
29  
30  public class RemoveCommand implements Command {
31  
32  
33      // -------------------------------------------------------------- Properties
34  
35  
36      private String fromKey = null;
37  
38  
39      /***
40       * <p>Return the context attribute key for the attribute.</p>
41       * @return The context attribute key.
42       */
43      public String getFromKey() {
44  
45      return (this.fromKey);
46  
47      }
48  
49  
50      /***
51       * <p>Set the context attribute key for the attribute.</p>
52       *
53       * @param fromKey The new key
54       */
55      public void setFromKey(String fromKey) {
56  
57      this.fromKey = fromKey;
58  
59      }
60  
61  
62      // ---------------------------------------------------------- Filter Methods
63  
64  
65      /***
66       * <p>Copy the specified source attribute to the specified destination
67       * attribute.</p>
68       *
69       * @param context {@link Context} in which we are operating
70       *
71       * @return <code>false</code> so that processing will continue
72       * @throws Exception if and error occurs.
73       */
74      public boolean execute(Context context) throws Exception {
75  
76      context.remove(getFromKey());
77      return (false);
78  
79      }
80  
81  
82  }