View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  
18  //
19  // This source code implements specifications defined by the Java
20  // Community Process. In order to remain compliant with the specification
21  // DO NOT add / change / or delete method signatures!
22  //
23  
24  package javax.servlet;
25  
26  /**
27   * This is the event class for notifications about changes to the
28   * attributes of the servlet request of a web application.
29   *
30   * @see ServletRequestAttributeListener
31   *
32   * @since Servlet 2.4
33   *
34   * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
35   */
36  public class ServletRequestAttributeEvent extends ServletRequestEvent {
37      private String name;
38      private Object value;
39  
40      /**
41       * Construct a ServletRequestAttributeEvent from the given context for the
42       * given attribute name and attribute value.
43       *
44       * @param sc the ServletContext that is sending the event.
45       * @param request the ServletRequest that is sending the event.
46       * @param name the name of the request attribute.
47       * @param value the value of the request attribute.
48       */
49      public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value) {
50          super(sc, request);
51          this.name = name;
52          this.value = value;
53      }
54  
55      /**
56       * Return the name of the attribute that changed on the ServletRequest.
57       *
58       * @return String the name of the changed request attribute.
59       */
60      public String getName() {
61          return this.name;
62      }
63  
64      /**
65       * Returns the value of the attribute that has been added removed or
66       * replaced. If the attribute was added, this is the value of the
67       * attribute. If the attribute was removed, this is the value of the
68       * removed attribute. If the attribute was replaced, this is the old
69       * value of the attribute.
70       *
71       * @return Object the value of the changed request attribute.
72       */
73      public Object getValue() {
74          return this.value;
75      }
76  }