1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.jms;
18
19 import java.util.Enumeration;
20 import java.util.concurrent.ConcurrentHashMap;
21 import javax.jms.Destination;
22 import javax.jms.JMSException;
23 import javax.jms.TextMessage;
24
25
26
27
28
29
30
31 public class StubTextMessage implements TextMessage {
32
33 private String messageId;
34
35 private String text;
36
37 private int deliveryMode = DEFAULT_DELIVERY_MODE;
38
39 private Destination destination;
40
41 private String correlationId;
42
43 private Destination replyTo;
44
45 private String type;
46
47 private long timestamp = 0L;
48
49 private long expiration = 0L;
50
51 private int priority = DEFAULT_PRIORITY;
52
53 private boolean redelivered;
54
55 private ConcurrentHashMap<String, Object> properties = new ConcurrentHashMap<String, Object>();
56
57
58 public StubTextMessage() {
59 }
60
61 public StubTextMessage(String text) {
62 this.text = text;
63 }
64
65
66 public String getText() throws JMSException {
67 return this.text;
68 }
69
70 public void setText(String text) throws JMSException {
71 this.text = text;
72 }
73
74 public void acknowledge() throws JMSException {
75 throw new UnsupportedOperationException();
76 }
77
78 public void clearBody() throws JMSException {
79 this.text = null;
80 }
81
82 public void clearProperties() throws JMSException {
83 this.properties.clear();
84 }
85
86 public boolean getBooleanProperty(String name) throws JMSException {
87 Object value = this.properties.get(name);
88 return (value instanceof Boolean) ? ((Boolean) value).booleanValue() : false;
89 }
90
91 public byte getByteProperty(String name) throws JMSException {
92 Object value = this.properties.get(name);
93 return (value instanceof Byte) ? ((Byte) value).byteValue() : 0;
94 }
95
96 public double getDoubleProperty(String name) throws JMSException {
97 Object value = this.properties.get(name);
98 return (value instanceof Double) ? ((Double) value).doubleValue() : 0;
99 }
100
101 public float getFloatProperty(String name) throws JMSException {
102 Object value = this.properties.get(name);
103 return (value instanceof Float) ? ((Float) value).floatValue() : 0;
104 }
105
106 public int getIntProperty(String name) throws JMSException {
107 Object value = this.properties.get(name);
108 return (value instanceof Integer) ? ((Integer) value).intValue() : 0;
109 }
110
111 public String getJMSCorrelationID() throws JMSException {
112 return this.correlationId;
113 }
114
115 public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
116 return this.correlationId.getBytes();
117 }
118
119 public int getJMSDeliveryMode() throws JMSException {
120 return this.deliveryMode;
121 }
122
123 public Destination getJMSDestination() throws JMSException {
124 return this.destination;
125 }
126
127 public long getJMSExpiration() throws JMSException {
128 return this.expiration;
129 }
130
131 public String getJMSMessageID() throws JMSException {
132 return this.messageId;
133 }
134
135 public int getJMSPriority() throws JMSException {
136 return this.priority;
137 }
138
139 public boolean getJMSRedelivered() throws JMSException {
140 return this.redelivered;
141 }
142
143 public Destination getJMSReplyTo() throws JMSException {
144 return this.replyTo;
145 }
146
147 public long getJMSTimestamp() throws JMSException {
148 return this.timestamp;
149 }
150
151 public String getJMSType() throws JMSException {
152 return this.type;
153 }
154
155 public long getLongProperty(String name) throws JMSException {
156 Object value = this.properties.get(name);
157 return (value instanceof Long) ? ((Long) value).longValue() : 0;
158 }
159
160 public Object getObjectProperty(String name) throws JMSException {
161 return this.properties.get(name);
162 }
163
164 public Enumeration<?> getPropertyNames() throws JMSException {
165 return this.properties.keys();
166 }
167
168 public short getShortProperty(String name) throws JMSException {
169 Object value = this.properties.get(name);
170 return (value instanceof Short) ? ((Short) value).shortValue() : 0;
171 }
172
173 public String getStringProperty(String name) throws JMSException {
174 Object value = this.properties.get(name);
175 return (value instanceof String) ? (String) value : null;
176 }
177
178 public boolean propertyExists(String name) throws JMSException {
179 return this.properties.containsKey(name);
180 }
181
182 public void setBooleanProperty(String name, boolean value) throws JMSException {
183 this.properties.put(name, value);
184 }
185
186 public void setByteProperty(String name, byte value) throws JMSException {
187 this.properties.put(name, value);
188 }
189
190 public void setDoubleProperty(String name, double value) throws JMSException {
191 this.properties.put(name, value);
192 }
193
194 public void setFloatProperty(String name, float value) throws JMSException {
195 this.properties.put(name, value);
196 }
197
198 public void setIntProperty(String name, int value) throws JMSException {
199 this.properties.put(name, value);
200 }
201
202 public void setJMSCorrelationID(String correlationId) throws JMSException {
203 this.correlationId = correlationId;
204 }
205
206 public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException {
207 this.correlationId = new String(correlationID);
208 }
209
210 public void setJMSDeliveryMode(int deliveryMode) throws JMSException {
211 this.deliveryMode = deliveryMode;
212 }
213
214 public void setJMSDestination(Destination destination) throws JMSException {
215 this.destination = destination;
216 }
217
218 public void setJMSExpiration(long expiration) throws JMSException {
219 this.expiration = expiration;
220 }
221
222 public void setJMSMessageID(String id) throws JMSException {
223 this.messageId = id;
224 }
225
226 public void setJMSPriority(int priority) throws JMSException {
227 this.priority = priority;
228 }
229
230 public void setJMSRedelivered(boolean redelivered) throws JMSException {
231 this.redelivered = redelivered;
232 }
233
234 public void setJMSReplyTo(Destination replyTo) throws JMSException {
235 this.replyTo = replyTo;
236 }
237
238 public void setJMSTimestamp(long timestamp) throws JMSException {
239 this.timestamp = timestamp;
240 }
241
242 public void setJMSType(String type) throws JMSException {
243 this.type = type;
244 }
245
246 public void setLongProperty(String name, long value) throws JMSException {
247 this.properties.put(name, value);
248 }
249
250 public void setObjectProperty(String name, Object value) throws JMSException {
251 this.properties.put(name, value);
252 }
253
254 public void setShortProperty(String name, short value) throws JMSException {
255 this.properties.put(name, value);
256 }
257
258 public void setStringProperty(String name, String value) throws JMSException {
259 this.properties.put(name, value);
260 }
261
262 }
263