Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BaseMessageDTO |
|
| 0.0;0 |
1 | /* | |
2 | * $Id: BaseMessageDTO.java 19191 2010-08-25 21:05:23Z tcarlson $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.message; | |
12 | ||
13 | import org.mule.transport.NullPayload; | |
14 | ||
15 | import java.io.Serializable; | |
16 | import java.util.HashMap; | |
17 | import java.util.Map; | |
18 | ||
19 | /** | |
20 | * <code>BaseMessage</code> A default message implementation used for messages sent | |
21 | * over the wire. client messages must NOT implement MuleMessage. | |
22 | */ | |
23 | public class BaseMessageDTO implements Serializable | |
24 | { | |
25 | /** | |
26 | * Serial version | |
27 | */ | |
28 | private static final long serialVersionUID = -6105691921086093748L; | |
29 | ||
30 | private Object payload; | |
31 | ||
32 | protected Map<String, Object> properties; | |
33 | ||
34 | public BaseMessageDTO() | |
35 | { | |
36 | 0 | this(NullPayload.getInstance()); |
37 | 0 | } |
38 | ||
39 | public BaseMessageDTO(Object payload) | |
40 | 0 | { |
41 | 0 | this.payload = payload; |
42 | 0 | properties = new HashMap<String, Object>(); |
43 | 0 | } |
44 | ||
45 | ||
46 | public void setPayload(Object payload) | |
47 | { | |
48 | 0 | this.payload = payload; |
49 | 0 | } |
50 | ||
51 | /** | |
52 | * @return the current message | |
53 | */ | |
54 | public Object getPayload() | |
55 | { | |
56 | 0 | return payload; |
57 | } | |
58 | ||
59 | ||
60 | /** | |
61 | * Adds a map of properties to associated with this message | |
62 | * | |
63 | * @param properties the properties add to this message | |
64 | */ | |
65 | public void addProperties(Map<String, Object> properties) | |
66 | { | |
67 | 0 | this.properties.putAll(properties); |
68 | 0 | } |
69 | ||
70 | /** | |
71 | * Removes all properties on this message | |
72 | */ | |
73 | public void clearProperties() | |
74 | { | |
75 | 0 | properties.clear(); |
76 | 0 | } |
77 | ||
78 | /** | |
79 | * Returns a map of all properties on this message | |
80 | * | |
81 | * @return a map of all properties on this message | |
82 | */ | |
83 | public Map getProperties() | |
84 | { | |
85 | 0 | return properties; |
86 | } | |
87 | ||
88 | public void setProperty(String key, Object value) | |
89 | { | |
90 | 0 | properties.put(key, value); |
91 | 0 | } |
92 | ||
93 | public Object getProperty(String key) | |
94 | { | |
95 | 0 | return properties.get(key); |
96 | } | |
97 | ||
98 | public String toString() | |
99 | { | |
100 | 0 | return "BaseMessageDTO{" + "payload=" + payload + ", properties=" + properties + "}"; |
101 | } | |
102 | } |