001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    package javax.servlet;
021    
022    
023    /**
024     * This is the event class for notifications of changes to the
025     * attributes of the servlet request in an application.
026     *
027     * @since Servlet 2.4
028     * @see ServletRequestAttributeListener
029     * @version $Rev: 788194 $ $Date: 2009-06-24 18:05:48 -0400 (Wed, 24 Jun 2009) $
030     */
031    
032    public class ServletRequestAttributeEvent extends ServletRequestEvent {
033        private final String name;
034        private final Object value;
035    
036        /**
037         * Construct a ServletRequestAttributeEvent giving the servlet context
038         * of this web application, the ServletRequest whose attributes are
039         * changing and the name and value of the attribute.
040         *
041         * @param sc      the ServletContext that is sending the event.
042         * @param request the ServletRequest that is sending the event.
043         * @param name    the name of the request attribute.
044         * @param value   the value of the request attribute.
045         */
046        public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value) {
047            super(sc, request);
048            this.name = name;
049            this.value = value;
050        }
051    
052        /**
053         * Return the name of the attribute that changed on the ServletRequest.
054         *
055         * @return the name of the changed request attribute
056         */
057        public String getName() {
058            return this.name;
059        }
060    
061        /**
062         * Returns the value of the attribute that has been added, removed or
063         * replaced. If the attribute was added, this is the value of the
064         * attribute. If the attribute was removed, this is the value of the
065         * removed attribute. If the attribute was replaced, this is the old
066         * value of the attribute.
067         *
068         * @return the value of the changed request attribute
069         */
070        public Object getValue() {
071            return this.value;   
072        }
073    }