001
014
015 package com.liferay.portal.kernel.messaging;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.kernel.util.StringBundler;
019
020 import java.io.Serializable;
021
022 import java.util.HashMap;
023 import java.util.Map;
024
025
029 public class Message implements Serializable {
030
031 public Object get(String key) {
032 if (_values == null) {
033 return null;
034 }
035 else {
036 return _values.get(key);
037 }
038 }
039
040 public boolean getBoolean(String key) {
041 boolean value;
042
043 Object object = get(key);
044
045 if (object instanceof Boolean) {
046 value = ((Boolean)object).booleanValue();
047 }
048 else {
049 value = GetterUtil.getBoolean((String)object);
050 }
051
052 return value;
053 }
054
055 public String getDestinationName() {
056 return _destinationName;
057 }
058
059 public double getDouble(String key) {
060 double value;
061
062 Object object = get(key);
063
064 if (object instanceof Number) {
065 value = ((Number)object).doubleValue();
066 }
067 else {
068 value = GetterUtil.getDouble((String)object);
069 }
070
071 return value;
072 }
073
074 public int getInteger(String key) {
075 int value;
076
077 Object object = get(key);
078
079 if (object instanceof Number) {
080 value = ((Number)object).intValue();
081 }
082 else {
083 value = GetterUtil.getInteger((String)object);
084 }
085
086 return value;
087 }
088
089 public long getLong(String key) {
090 long value;
091
092 Object object = get(key);
093
094 if (object instanceof Number) {
095 value = ((Number)object).longValue();
096 }
097 else {
098 value = GetterUtil.getLong((String)object);
099 }
100
101 return value;
102 }
103
104 public Object getPayload() {
105 return _payload;
106 }
107
108 public String getResponseDestinationName() {
109 return _responseDestinationName;
110 }
111
112 public String getResponseId() {
113 return _responseId;
114 }
115
116 public String getString(String key) {
117 return GetterUtil.getString(String.valueOf(get(key)));
118 }
119
120 public void put(String key, Object value) {
121 if (_values == null) {
122 _values = new HashMap<String, Object>();
123 }
124
125 _values.put(key, value);
126 }
127
128 public void setDestinationName(String destinationName) {
129 _destinationName = destinationName;
130 }
131
132 public void setPayload(Object payload) {
133 _payload = payload;
134 }
135
136 public void setResponseDestinationName(String responseDestinationName) {
137 _responseDestinationName = responseDestinationName;
138 }
139
140 public void setResponseId(String responseId) {
141 _responseId = responseId;
142 }
143
144 public String toString() {
145 StringBundler sb = new StringBundler(11);
146
147 sb.append("{destinationName=");
148 sb.append(_destinationName);
149 sb.append(", responseDestinationName=");
150 sb.append(_responseDestinationName);
151 sb.append(", responseId=");
152 sb.append(_responseId);
153 sb.append(", payload=");
154 sb.append(_payload);
155 sb.append(", values=");
156 sb.append(_values);
157 sb.append("}");
158
159 return sb.toString();
160 }
161
162 private String _destinationName;
163 private Object _payload;
164 private String _responseDestinationName;
165 private String _responseId;
166 private Map<String, Object> _values;
167
168 }