View Javadoc

1   /*
2   * Copyright 2004 The Apache Software Foundation
3   *
4   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *     http://www.apache.org/licenses/LICENSE-2.0
9   *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16  package javax.servlet;
17  
18  
19      /** 
20        * This is the event class for notifications of changes to the 
21        * attributes of the servlet request in an application.
22        * @see ServletRequestAttributeListener
23        * @since	Servlet 2.4
24        */
25  
26  public class ServletRequestAttributeEvent extends ServletRequestEvent { 
27      private String name;
28      private Object value;
29  
30       /** Construct a ServletRequestAttributeEvent giving the servlet context
31        * of this web application, the ServletRequest whose attributes are
32        * changing and the name and value of the attribute.
33        *
34        * @param sc		the ServletContext that is sending the event.
35        * @param request		the ServletRequest that is sending the event.
36        * @param name		the name of the request attribute.
37        * @param value		the value of the request attribute.
38        */
39      public ServletRequestAttributeEvent(ServletContext sc, ServletRequest request, String name, Object value) {
40          super(sc, request);
41          this.name = name;
42          this.value = value;
43      }
44  
45      /**
46        * Return the name of the attribute that changed on the ServletRequest.
47        *
48        * @return		the name of the changed request attribute
49        */
50      public String getName() {
51          return this.name;
52      }
53  
54      /**
55        * Returns the value of the attribute that has been added, removed or 
56        * replaced. If the attribute was added, this is the value of the 
57        * attribute. If the attribute was removed, this is the value of the 
58        * removed attribute. If the attribute was replaced, this is the old 
59        * value of the attribute.
60        *
61        * @return		the value of the changed request attribute
62        */
63      public Object getValue() {
64          return this.value;   
65      }
66  }