001 /**
002 *
003 * Copyright 2003-2004 The Apache Software Foundation
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * 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
018 //
019 // This source code implements specifications defined by the Java
020 // Community Process. In order to remain compliant with the specification
021 // DO NOT add / change / or delete method signatures!
022 //
023
024 package javax.servlet;
025
026 /**
027 * This is the event class for notifications about changes to the
028 * attributes of the servlet request of a web application.
029 *
030 * @see ServletRequestAttributeListener
031 *
032 * @since Servlet 2.4
033 *
034 * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
035 */
036 public class ServletRequestAttributeEvent extends ServletRequestEvent {
037 private String name;
038 private Object value;
039
040 /**
041 * Construct a ServletRequestAttributeEvent from the given context for the
042 * given attribute name and attribute value.
043 *
044 * @param sc the ServletContext that is sending the event.
045 * @param request the ServletRequest that is sending the event.
046 * @param name the name of the request attribute.
047 * @param value the value of the request attribute.
048 */
049 public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value) {
050 super(sc, request);
051 this.name = name;
052 this.value = value;
053 }
054
055 /**
056 * Return the name of the attribute that changed on the ServletRequest.
057 *
058 * @return String the name of the changed request attribute.
059 */
060 public String getName() {
061 return this.name;
062 }
063
064 /**
065 * Returns the value of the attribute that has been added removed or
066 * replaced. If the attribute was added, this is the value of the
067 * attribute. If the attribute was removed, this is the value of the
068 * removed attribute. If the attribute was replaced, this is the old
069 * value of the attribute.
070 *
071 * @return Object the value of the changed request attribute.
072 */
073 public Object getValue() {
074 return this.value;
075 }
076 }