001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.chain.generic;
018    
019    
020    import org.apache.commons.chain.Command;
021    import org.apache.commons.chain.Context;
022    
023    
024    /**
025     * <p>Remove any context attribute stored under the <code>fromKey</code>.</p>
026     *
027     * @author Craig R. McClanahan
028     * @version $Revision: 480477 $ $Date: 2006-11-29 08:34:52 +0000 (Wed, 29 Nov 2006) $
029     */
030    
031    public class RemoveCommand implements Command {
032    
033    
034        // -------------------------------------------------------------- Properties
035    
036    
037        private String fromKey = null;
038    
039    
040        /**
041         * <p>Return the context attribute key for the attribute.</p>
042         * @return The context attribute key.
043         */
044        public String getFromKey() {
045    
046        return (this.fromKey);
047    
048        }
049    
050    
051        /**
052         * <p>Set the context attribute key for the attribute.</p>
053         *
054         * @param fromKey The new key
055         */
056        public void setFromKey(String fromKey) {
057    
058        this.fromKey = fromKey;
059    
060        }
061    
062    
063        // ---------------------------------------------------------- Filter Methods
064    
065    
066        /**
067         * <p>Copy the specified source attribute to the specified destination
068         * attribute.</p>
069         *
070         * @param context {@link Context} in which we are operating
071         *
072         * @return <code>false</code> so that processing will continue
073         * @throws Exception if and error occurs.
074         */
075        public boolean execute(Context context) throws Exception {
076    
077        context.remove(getFromKey());
078        return (false);
079    
080        }
081    
082    
083    }