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 public String getDestinationName() {
58 return _destinationName;
59 }
60
61 public double getDouble(String key) {
62 double value;
63
64 Object object = get(key);
65
66 if (object instanceof Number) {
67 value = ((Number)object).doubleValue();
68 }
69 else {
70 value = GetterUtil.getDouble((String)object);
71 }
72
73 return value;
74 }
75
76 public int getInteger(String key) {
77 int value;
78
79 Object object = get(key);
80
81 if (object instanceof Number) {
82 value = ((Number)object).intValue();
83 }
84 else {
85 value = GetterUtil.getInteger((String)object);
86 }
87
88 return value;
89 }
90
91 public long getLong(String key) {
92 long value;
93
94 Object object = get(key);
95
96 if (object instanceof Number) {
97 value = ((Number)object).longValue();
98 }
99 else {
100 value = GetterUtil.getLong((String)object);
101 }
102
103 return value;
104 }
105
106 public Object getPayload() {
107 return _payload;
108 }
109
110 public String getResponseDestinationName() {
111 return _responseDestinationName;
112 }
113
114 public String getResponseId() {
115 return _responseId;
116 }
117
118 public String getString(String key) {
119 return GetterUtil.getString(String.valueOf(get(key)));
120 }
121
122 public void put(String key, Object value) {
123 if (_values == null) {
124 _values = new HashMap<String, Object>();
125 }
126
127 _values.put(key, value);
128 }
129
130 public void setDestinationName(String destinationName) {
131 _destinationName = destinationName;
132 }
133
134 public void setPayload(Object payload) {
135 _payload = payload;
136 }
137
138 public void setResponseDestinationName(String responseDestinationName) {
139 _responseDestinationName = responseDestinationName;
140 }
141
142 public void setResponseId(String responseId) {
143 _responseId = responseId;
144 }
145
146 public String toString() {
147 StringBundler sb = new StringBundler(11);
148
149 sb.append("{destinationName=");
150 sb.append(_destinationName);
151 sb.append(", responseDestinationName=");
152 sb.append(_responseDestinationName);
153 sb.append(", responseId=");
154 sb.append(_responseId);
155 sb.append(", payload=");
156 sb.append(_payload);
157 sb.append(", values=");
158 sb.append(_values);
159 sb.append("}");
160
161 return sb.toString();
162 }
163
164 private String _destinationName;
165 private Object _payload;
166 private String _responseDestinationName;
167 private String _responseId;
168 private Map<String, Object> _values;
169
170 }