1
14
15 package com.liferay.portal.kernel.messaging;
16
17 import com.liferay.portal.kernel.util.GetterUtil;
18 import com.liferay.portal.kernel.util.StringBundler;
19
20 import java.io.Serializable;
21
22 import java.util.HashMap;
23 import java.util.Map;
24
25
31 public class Message implements Serializable {
32
33 public Object get(String key) {
34 if (_values == null) {
35 return null;
36 }
37 else {
38 return _values.get(key);
39 }
40 }
41
42 public boolean getBoolean(String key) {
43 boolean value;
44
45 Object object = get(key);
46
47 if (object instanceof Boolean) {
48 value = ((Boolean)object).booleanValue();
49 }
50 else {
51 value = GetterUtil.getBoolean((String)object);
52 }
53
54 return value;
55 }
56
57
60 public String getDestination() {
61 return getDestinationName();
62 }
63
64 public String getDestinationName() {
65 return _destinationName;
66 }
67
68 public double getDouble(String key) {
69 double value;
70
71 Object object = get(key);
72
73 if (object instanceof Number) {
74 value = ((Number)object).doubleValue();
75 }
76 else {
77 value = GetterUtil.getDouble((String)object);
78 }
79
80 return value;
81 }
82
83 public int getInteger(String key) {
84 int value;
85
86 Object object = get(key);
87
88 if (object instanceof Number) {
89 value = ((Number)object).intValue();
90 }
91 else {
92 value = GetterUtil.getInteger((String)object);
93 }
94
95 return value;
96 }
97
98 public long getLong(String key) {
99 long value;
100
101 Object object = get(key);
102
103 if (object instanceof Number) {
104 value = ((Number)object).longValue();
105 }
106 else {
107 value = GetterUtil.getLong((String)object);
108 }
109
110 return value;
111 }
112
113 public Object getPayload() {
114 return _payload;
115 }
116
117
120 public String getResponseDestination() {
121 return getResponseDestinationName();
122 }
123
124 public String getResponseDestinationName() {
125 return _responseDestinationName;
126 }
127
128 public String getResponseId() {
129 return _responseId;
130 }
131
132 public String getString(String key) {
133 return GetterUtil.getString(String.valueOf(get(key)));
134 }
135
136 public void put(String key, Object value) {
137 if (_values == null) {
138 _values = new HashMap<String, Object>();
139 }
140
141 _values.put(key, value);
142 }
143
144 public void setDestinationName(String destinationName) {
145 _destinationName = destinationName;
146 }
147
148 public void setPayload(Object payload) {
149 _payload = payload;
150 }
151
152 public void setResponseDestinationName(String responseDestinationName) {
153 _responseDestinationName = responseDestinationName;
154 }
155
156 public void setResponseId(String responseId) {
157 _responseId = responseId;
158 }
159
160 public String toString() {
161 StringBundler sb = new StringBundler(11);
162
163 sb.append("{destinationName=");
164 sb.append(_destinationName);
165 sb.append(", responseDestinationName=");
166 sb.append(_responseDestinationName);
167 sb.append(", responseId=");
168 sb.append(_responseId);
169 sb.append(", payload=");
170 sb.append(_payload);
171 sb.append(", values=");
172 sb.append(_values);
173 sb.append("}");
174
175 return sb.toString();
176 }
177
178 private String _destinationName;
179 private Object _payload;
180 private String _responseDestinationName;
181 private String _responseId;
182 private Map<String, Object> _values;
183
184 }