KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > AcknowledgementRequest


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq;
23
24 import java.io.Externalizable JavaDoc;
25
26 import javax.jms.Destination JavaDoc;
27
28 /**
29  * Used to Acknowledge sent messages.
30  * <p>
31  * This class holds the minimum amount of information needed to identify a
32  * message to the JMSServer.
33  *
34  * @author Hiram Chirino (Cojonudo14@hotmail.com)
35  * @author David Maplesden (David.Maplesden@orion.co.nz)
36  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
37  * @version $Revision: 37459 $
38  */

39 public class AcknowledgementRequest implements Externalizable JavaDoc
40 {
41    // Constants -----------------------------------------------------
42

43    /** The serialVersionUID */
44    private static final long serialVersionUID = -2227528634302168874L;
45    
46    // Attributes ----------------------------------------------------
47

48    /** Is it an acknowledgement */
49    public boolean isAck;
50    /** The destination */
51    public Destination JavaDoc destination = null;
52    /** The messageID */
53    public String JavaDoc messageID = null;
54    /** The subscriberId */
55    public int subscriberId;
56    
57    // Static --------------------------------------------------------
58

59    // Constructors --------------------------------------------------
60

61    public AcknowledgementRequest()
62    {
63       this(false);
64    }
65
66    public AcknowledgementRequest(boolean ack)
67    {
68       this.isAck = ack;
69    }
70    
71    // Public --------------------------------------------------------
72

73    public boolean isAck()
74    {
75       return isAck;
76    }
77    
78    // Object overrides ----------------------------------------------
79

80    public boolean equals(Object JavaDoc o)
81    {
82
83       if (!(o instanceof AcknowledgementRequest))
84       {
85          return false;
86       }
87
88       return messageID.equals(((AcknowledgementRequest) o).messageID)
89             && destination.equals(((AcknowledgementRequest) o).destination)
90             && subscriberId == ((AcknowledgementRequest) o).subscriberId;
91    }
92
93    public int hashCode()
94    {
95       return messageID.hashCode();
96    }
97
98    public String JavaDoc toString()
99    {
100       return "AcknowledgementRequest:" +
101          ((isAck) ? "ACK" : "NACK") + "," + destination + "," + messageID;
102    }
103
104    public void readExternal(java.io.ObjectInput JavaDoc in) throws java.io.IOException JavaDoc
105    {
106       isAck = in.readBoolean();
107       destination = SpyDestination.readDest(in);
108       messageID = in.readUTF();
109       subscriberId = in.readInt();
110    }
111    
112    // Externalizable implementation ---------------------------------
113

114    public void writeExternal(java.io.ObjectOutput JavaDoc out) throws java.io.IOException JavaDoc
115    {
116       out.writeBoolean(isAck);
117       SpyDestination.writeDest(out, destination);
118       out.writeUTF(messageID);
119       out.writeInt(subscriberId);
120    }
121    
122    // Package protected ---------------------------------------------
123

124    // Protected -----------------------------------------------------
125

126    // Private -------------------------------------------------------
127

128    // Inner classes -------------------------------------------------
129
}
130
Popular Tags