KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > dq > DQMessage


1 /*
2  * $Id: DQMessage.java 3982 2006-11-22 14:28:01Z lajos $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.dq;
12
13 import java.io.Serializable JavaDoc;
14 import java.util.ArrayList JavaDoc;
15 import java.util.HashMap JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.LinkedHashMap JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Map JavaDoc;
20
21 /**
22  * <code>DQMessage</code> is an encapsulation of a DataQueue message.
23  */

24 public class DQMessage implements Serializable JavaDoc
25 {
26     /**
27      * Serial version
28      */

29     private static final long serialVersionUID = 5819476148531491540L;
30
31     public static final String JavaDoc XML_ROOT = "DQMessage";
32     public static final String JavaDoc XML_ENTRY = "entry";
33     public static final String JavaDoc XML_NAME = "name";
34
35     private Map JavaDoc entries = new HashMap JavaDoc();
36     private String JavaDoc senderInformation;
37
38     /**
39      * @return Returns the senderInformation.
40      */

41     public final String JavaDoc getSenderInformation()
42     {
43         return senderInformation;
44     }
45
46     /**
47      * @param pSenderInformation The senderInformation to set.
48      */

49     public final void setSenderInformation(final String JavaDoc pSenderInformation)
50     {
51         senderInformation = pSenderInformation;
52     }
53
54     /**
55      * Constructor
56      */

57     public DQMessage()
58     {
59         super();
60     }
61
62     /**
63      * The constructor
64      *
65      * @param pMessage The message
66      */

67     public DQMessage(final DQMessage pMessage)
68     {
69         this();
70         if (pMessage == null)
71         {
72             return;
73         }
74         this.entries = new LinkedHashMap JavaDoc(pMessage.entries);
75         this.senderInformation = pMessage.senderInformation;
76     }
77
78     /**
79      * Add an entry
80      *
81      * @param name The name
82      * @param value The value
83      */

84     public final void addEntry(final String JavaDoc name, final Object JavaDoc value)
85     {
86         entries.put(name, value);
87     }
88
89     /**
90      * Returns a value entry by name
91      *
92      * @param name The name
93      * @return The value
94      */

95     public final Object JavaDoc getEntry(final String JavaDoc name)
96     {
97         return entries.get(name);
98     }
99
100     /**
101      * @return The entries
102      */

103     public final Iterator JavaDoc getEntries()
104     {
105         return entries.values().iterator();
106     }
107
108     /**
109      * @return The entry names
110      */

111     public final List JavaDoc getEntryNames()
112     {
113         ArrayList JavaDoc list = new ArrayList JavaDoc();
114
115         Iterator JavaDoc it = entries.keySet().iterator();
116
117         while (it.hasNext())
118         {
119             list.add(it.next());
120         }
121
122         return list;
123     }
124
125     public boolean equals(Object JavaDoc o)
126     {
127         if (this == o)
128         {
129             return true;
130         }
131         if (!(o instanceof DQMessage))
132         {
133             return false;
134         }
135         final DQMessage dqMessage = (DQMessage)o;
136         if (entries != null ? !entries.equals(dqMessage.entries) : dqMessage.entries != null)
137         {
138             return false;
139         }
140         if (senderInformation != null
141                         ? !senderInformation.equals(dqMessage.senderInformation)
142                         : dqMessage.senderInformation != null)
143         {
144             return false;
145         }
146         return true;
147     }
148
149     public int hashCode()
150     {
151         int result;
152         result = (entries != null ? entries.hashCode() : 0);
153         result = 29 * result + (senderInformation != null ? senderInformation.hashCode() : 0);
154         return result;
155     }
156 }
157
Popular Tags