1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.expression; |
8 | |
|
9 | |
import org.mule.api.MuleMessage; |
10 | |
|
11 | |
import java.util.Collection; |
12 | |
import java.util.HashMap; |
13 | |
import java.util.Map; |
14 | |
import java.util.Set; |
15 | |
|
16 | |
import javax.activation.DataHandler; |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | 0 | public class InboundAttachmentsMap implements Map<String, DataHandler> |
23 | |
{ |
24 | |
private MuleMessage message; |
25 | |
|
26 | |
public InboundAttachmentsMap(MuleMessage message) |
27 | 0 | { |
28 | 0 | this.message = message; |
29 | 0 | } |
30 | |
|
31 | |
public int size() |
32 | |
{ |
33 | 0 | return message.getInboundAttachmentNames().size(); |
34 | |
} |
35 | |
|
36 | |
public boolean isEmpty() |
37 | |
{ |
38 | 0 | return message.getInboundAttachmentNames().size() == 0; |
39 | |
} |
40 | |
|
41 | |
public boolean containsKey(Object key) |
42 | |
{ |
43 | 0 | return message.getInboundAttachmentNames().contains(key.toString()); |
44 | |
} |
45 | |
|
46 | |
public boolean containsValue(Object value) |
47 | |
{ |
48 | 0 | return values().contains(value); |
49 | |
} |
50 | |
|
51 | |
public DataHandler get(Object key) |
52 | |
{ |
53 | 0 | return message.getInboundAttachment(key.toString()); |
54 | |
} |
55 | |
|
56 | |
public DataHandler put(String key, DataHandler value) |
57 | |
{ |
58 | 0 | throw new UnsupportedOperationException("put(): Inbound attachments are read-only"); |
59 | |
} |
60 | |
|
61 | |
|
62 | |
public DataHandler remove(Object key) |
63 | |
{ |
64 | 0 | throw new UnsupportedOperationException("remove(): Inbound attachments are read-only"); |
65 | |
} |
66 | |
|
67 | |
|
68 | |
public void putAll(Map<? extends String, ? extends DataHandler> map) |
69 | |
{ |
70 | 0 | for (Entry<? extends String, ? extends DataHandler> entry : map.entrySet()) |
71 | |
{ |
72 | 0 | put(entry.getKey(), entry.getValue()); |
73 | |
} |
74 | 0 | } |
75 | |
|
76 | |
public void clear() |
77 | |
{ |
78 | 0 | throw new UnsupportedOperationException("clear"); |
79 | |
} |
80 | |
|
81 | |
public Set<String> keySet() |
82 | |
{ |
83 | 0 | return message.getInboundAttachmentNames(); |
84 | |
} |
85 | |
|
86 | |
public Collection<DataHandler> values() |
87 | |
{ |
88 | 0 | return getAttachments().values(); |
89 | |
} |
90 | |
|
91 | |
public Set<Entry<String, DataHandler>> entrySet() |
92 | |
{ |
93 | 0 | return getAttachments().entrySet(); |
94 | |
} |
95 | |
|
96 | |
|
97 | |
private Map<String, DataHandler> getAttachments() |
98 | |
{ |
99 | 0 | Map<String, DataHandler> props = new HashMap<String, DataHandler>(); |
100 | 0 | for (String s : message.getInboundAttachmentNames()) |
101 | |
{ |
102 | 0 | props.put(s, message.getInboundAttachment(s)); |
103 | |
} |
104 | 0 | return props; |
105 | |
} |
106 | |
} |