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    //
021    // This source code implements specifications defined by the Java
022    // Community Process. In order to remain compliant with the specification
023    // DO NOT add / change / or delete method signatures!
024    //
025    
026    package javax.servlet;
027    
028    /**
029     * This is the event class for notifications about changes to the
030     * attributes of the servlet request of a web application.
031     *
032     * @see ServletRequestAttributeListener
033     *
034     * @since Servlet 2.4
035     *
036     * @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (Mi, 25. Okt 2006) $
037     */
038    public class ServletRequestAttributeEvent extends ServletRequestEvent {
039        private String name;
040        private Object value;
041    
042        /**
043         * Construct a ServletRequestAttributeEvent from the given context for the
044         * given attribute name and attribute value.
045         *
046         * @param sc the ServletContext that is sending the event.
047         * @param request the ServletRequest that is sending the event.
048         * @param name the name of the request attribute.
049         * @param value the value of the request attribute.
050         */
051        public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value) {
052            super(sc, request);
053            this.name = name;
054            this.value = value;
055        }
056    
057        /**
058         * Return the name of the attribute that changed on the ServletRequest.
059         *
060         * @return String the name of the changed request attribute.
061         */
062        public String getName() {
063            return this.name;
064        }
065    
066        /**
067         * Returns the value of the attribute that has been added removed or
068         * replaced. If the attribute was added, this is the value of the
069         * attribute. If the attribute was removed, this is the value of the
070         * removed attribute. If the attribute was replaced, this is the old
071         * value of the attribute.
072         *
073         * @return Object the value of the changed request attribute.
074         */
075        public Object getValue() {
076            return this.value;
077        }
078    }