View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   
6   package com.hack23.cia.service.api.application;
7   
8   import java.util.Map;
9   
10  import com.hack23.cia.service.api.common.AbstractServiceRequest;
11  
12  /***
13   * The Class ApplicationRequest.
14   */
15  public class ApplicationRequest extends AbstractServiceRequest {
16  
17      /***
18       * The Enum HeaderAttributeKey.
19       */
20      public enum HeaderAttributeKey {
21  
22          /*** The CLIEN t_ inf o_ address. */
23          CLIENT_INFO_ADDRESS,
24  
25          /*** The CLIEN t_ inf o_ host. */
26          CLIENT_INFO_HOST,
27  
28          /*** The CLIEN t_ inf o_ user. */
29          CLIENT_INFO_USER,
30  
31          /*** The HEADE r_ cookie. */
32          HEADER_COOKIE,
33  
34          /*** The HEADE r_ host. */
35          HEADER_HOST;
36      }
37  
38      /*** The Constant HEADER_ACCEPT_LANGUAGE. */
39      public static final String HEADER_ACCEPT_LANGUAGE = "HEADER_ACCEPT-LANGUAGE";
40  
41      /*** The Constant HEADER_USER_AGENT. */
42      public static final String HEADER_USER_AGENT = "HEADER_USER-AGENT";
43  
44      /*** The Constant serialVersionUID. */
45      private static final long serialVersionUID = 1L;
46  
47      /*** The user settings map. */
48      private final Map<String, String> userSettingsMap;
49  
50      /***
51       * Instantiates a new application request.
52       *
53       * @param userSettingsMap the user settings map
54       */
55      public ApplicationRequest(final Map<String, String> userSettingsMap) {
56          super(null);
57          this.userSettingsMap = userSettingsMap;
58      }
59  
60      /***
61       * Gets the accept language.
62       *
63       * @return the accept language
64       */
65      public final String getAcceptLanguage() {
66          return userSettingsMap.get(HEADER_ACCEPT_LANGUAGE);
67      }
68  
69      /***
70       * Gets the header attribute.
71       *
72       * @param headerAttributeKey the header attribute key
73       * @return the header attribute
74       */
75      public final String getHeaderAttribute(
76              final HeaderAttributeKey headerAttributeKey) {
77          final String string = headerAttributeKey.toString();
78          return userSettingsMap.get(string);
79      }
80  
81      /***
82       * Gets the user agent.
83       *
84       * @return the user agent
85       */
86      public final String getUserAgent() {
87          return userSettingsMap.get(HEADER_USER_AGENT);
88      }
89  
90  }