KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > queue > SequenceNumberChunkImpl


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.queue;
26
27 import java.io.Externalizable JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.io.ObjectInput JavaDoc;
30 import java.io.ObjectOutput JavaDoc;
31
32 import org.objectweb.dream.message.AbstractChunk;
33 import org.objectweb.dream.message.Chunk;
34 import org.objectweb.dream.message.ChunkType;
35
36 /**
37  * Basic implementation of the {@link SequenceNumberChunk}interface.
38  */

39 public class SequenceNumberChunkImpl extends AbstractChunk
40     implements
41       SequenceNumberChunk,
42       Externalizable JavaDoc
43 {
44   /** The sequence number. */
45   protected long sn;
46
47   // ---------------------------------------------------------------------------
48
// Implementation of the SequenceNumberChunk interface.
49
// ---------------------------------------------------------------------------
50

51   /**
52    * @see org.objectweb.dream.queue.SequenceNumberChunk#getSequenceNumber()
53    */

54   public long getSequenceNumber()
55   {
56     return sn;
57   }
58
59   /**
60    * @see org.objectweb.dream.queue.SequenceNumberChunk#setSequenceNumber(long)
61    */

62   public void setSequenceNumber(long sn)
63   {
64     this.sn = sn;
65   }
66
67   // ---------------------------------------------------------------------------
68
// Implementation of the Chunk interface
69
// ---------------------------------------------------------------------------
70

71   /**
72    * @see Chunk#getType()
73    */

74   public ChunkType getType()
75   {
76     return TYPE;
77   }
78
79   /**
80    * @see Chunk#transfertState(Chunk)
81    */

82   public void transfertState(Chunk newInstance)
83   {
84     ((SequenceNumberChunk) newInstance).setSequenceNumber(getSequenceNumber());
85   }
86
87   /**
88    * @see Chunk#recycle()
89    */

90   public void recycle()
91   {
92     sn = -1;
93   }
94
95   // ---------------------------------------------------------------------------
96
// Implementation of the serialization methods
97
// ---------------------------------------------------------------------------
98

99   /**
100    * @see Externalizable#readExternal(ObjectInput)
101    */

102   public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc,
103       ClassNotFoundException JavaDoc
104   {
105     sn = in.readLong();
106   }
107
108   /**
109    * @see Externalizable#writeExternal(ObjectOutput)
110    */

111   public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
112   {
113     out.writeLong(sn);
114   }
115
116 }
Popular Tags