View Javadoc

1   /*
2    * $Id: HistoricRequest.java 132 2004-11-28 13:35:12Z josem $
3    *
4    * Tarsis
5    * Copyright (C) 2002 Talika Open Source Group
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   *
21   */
22  
23  package org.talika.tarsis.filters.validator;
24  
25  import javax.servlet.http.HttpServletRequest;
26  
27  import java.util.Map;
28  import java.util.HashMap;
29  import java.util.Enumeration;
30  
31  /**
32   * Client's request history container.<br>
33   * Part of experimental extended validator filter. Work in progress.
34   *
35   * @author  Jose M. Palomar
36   * @version $Revision: 132 $
37   */
38  public final class HistoricRequest {
39  
40      // Fields
41      /**
42       * Request ticket.
43       */
44      private String ticket;
45  
46      /**
47       * Request parameters.
48       */
49      private Map parameters;
50  
51      /**
52       * Request attributes.
53       */
54      private Map attributes;
55  
56      // Constructors
57      /**
58       * Creates a new <code>HistoricRequest</code> object.
59       *
60       * @param ticket String client's request ticket.
61       * @param request HttpServletRequest client's request.
62       */
63      public HistoricRequest(String ticket, HttpServletRequest request) {
64  
65          // Ticket
66          this.ticket = ticket;
67  
68          // Parameters
69          this.parameters = new HashMap(request.getParameterMap());
70  
71          // Atributes
72          this.attributes = new HashMap();
73  
74          Enumeration atts = request.getAttributeNames();
75          while (atts.hasMoreElements()) {
76              String attName = (String) atts.nextElement();
77              Object attValue = request.getAttribute(attName);
78  
79              this.attributes.put(attName, attValue);
80          }
81  
82      }
83  
84      // Methods
85      /**
86       * Returns request's ticket.
87       *
88       * @return String request's ticket.
89       */
90      public String getTicket() {
91          return ticket;
92      }
93  
94      /**
95       * Returns request's parameters map.
96       *
97       * @return Map request's parameters map.
98       */
99      public Map getParameters() {
100         return parameters;
101     }
102 
103     /**
104      * Returns request's attributes map.
105      *
106      * @return Map request's attributes map.
107      */
108     public Map getAttributes() {
109         return attributes;
110     }
111 
112 }