1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.poller;
16  
17  import com.liferay.portal.kernel.util.StringBundler;
18  import com.liferay.portal.kernel.util.Validator;
19  
20  import java.util.Map;
21  
22  /**
23   * <a href="PollerRequest.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class PollerRequest {
28  
29      public PollerRequest(
30          PollerHeader pollerHeader, String portletId,
31          Map<String, String> parameterMap, String chunkId,
32          boolean receiveRequest) {
33  
34          _pollerHeader = pollerHeader;
35          _portletId = portletId;
36          _parameterMap = parameterMap;
37          _chunkId = chunkId;
38          _receiveRequest = receiveRequest;
39      }
40  
41      public boolean equals(Object obj) {
42          if (this == obj) {
43              return true;
44          }
45  
46          if (!(obj instanceof PollerRequest)) {
47              return false;
48          }
49  
50          PollerRequest portletRequest = (PollerRequest)obj;
51  
52          if (Validator.equals(_portletId, portletRequest._portletId)) {
53              return true;
54          }
55  
56          return false;
57      }
58  
59      public long getBrowserKey() {
60          return _pollerHeader.getBrowserKey();
61      }
62  
63      public String getChunkId() {
64          return _chunkId;
65      }
66  
67      public Map<String, String> getParameterMap() {
68          return _parameterMap;
69      }
70  
71      public PollerHeader getPollerHeader() {
72          return _pollerHeader;
73      }
74  
75      public String getPortletId() {
76          return _portletId;
77      }
78  
79      public String[] getPortletIds() {
80          return _pollerHeader.getPortletIds();
81      }
82  
83      public long getTimestamp() {
84          return _pollerHeader.getTimestamp();
85      }
86  
87      public long getUserId() {
88          return _pollerHeader.getUserId();
89      }
90  
91      public int hashCode() {
92          if (_portletId != null) {
93              return _portletId.hashCode();
94          }
95          else {
96              return 0;
97          }
98      }
99  
100     public boolean isInitialRequest() {
101         return _pollerHeader.isInitialRequest();
102     }
103 
104     public boolean isReceiveRequest() {
105         return _receiveRequest;
106     }
107 
108     public boolean isStartPolling() {
109         return _pollerHeader.isStartPolling();
110     }
111 
112     public String toString() {
113         StringBundler sb = new StringBundler(11);
114 
115         sb.append("{chunkId=");
116         sb.append(_chunkId);
117         sb.append(", parameterMap=");
118         sb.append(_parameterMap);
119         sb.append(", pollerHeader=");
120         sb.append(_pollerHeader);
121         sb.append(", portletId=");
122         sb.append(_portletId);
123         sb.append(", receiveRequest=");
124         sb.append(_receiveRequest);
125         sb.append("}");
126 
127         return sb.toString();
128     }
129 
130     private String _chunkId;
131     private Map<String, String> _parameterMap;
132     private PollerHeader _pollerHeader;
133     private String _portletId;
134     private boolean _receiveRequest;
135 
136 }