KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > protocol > ArrowChunkImpl


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): Matthieu Leclercq
22  * Contributor(s): Vivien Quema
23  */

24
25 package org.objectweb.dream.protocol;
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  * A basic Chunk interface that defines an arrow from a source process to a
38  * destination process.
39  */

40 public class ArrowChunkImpl extends AbstractChunk
41     implements
42       ArrowChunk,
43       Chunk,
44       Externalizable JavaDoc
45 {
46
47   private short processFrom;
48   private short processTo;
49
50   // ---------------------------------------------------------------------------
51
// Implementation of the ArrowChunk interface
52
// ---------------------------------------------------------------------------
53

54   /**
55    * @see ArrowChunk#getProcessIdFrom()
56    */

57   public short getProcessIdFrom()
58   {
59     return processFrom;
60   }
61
62   /**
63    * @see ArrowChunk#setProcessIdFrom(short)
64    */

65   public void setProcessIdFrom(short from)
66   {
67     processFrom = from;
68   }
69
70   /**
71    * @see ArrowChunk#getProcessIdTo()
72    */

73   public short getProcessIdTo()
74   {
75     return processTo;
76   }
77
78   /**
79    * @see ArrowChunk#setProcessIdTo(short)
80    */

81   public void setProcessIdTo(short to)
82   {
83     processTo = to;
84   }
85
86   // ---------------------------------------------------------------------------
87
// Implementation of the Chunk interface
88
// ---------------------------------------------------------------------------
89

90   /**
91    * @see Chunk#getType()
92    */

93   public ChunkType getType()
94   {
95     return ArrowChunk.TYPE;
96   }
97
98   /**
99    * @see Chunk#recycle()
100    */

101   public void recycle()
102   {
103   }
104
105   /**
106    * @see Chunk#transfertState(Chunk)
107    */

108   public void transfertState(Chunk newInstance)
109   {
110     ArrowChunk newInst = (ArrowChunk) newInstance;
111     newInst.setProcessIdFrom(getProcessIdFrom());
112     newInst.setProcessIdTo(getProcessIdTo());
113   }
114
115   // ---------------------------------------------------------------------------
116
// Implementation of the serialization methods
117
// ---------------------------------------------------------------------------
118

119   /**
120    * @see Externalizable#readExternal(ObjectInput)
121    */

122   public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc,
123       ClassNotFoundException JavaDoc
124   {
125     processFrom = in.readShort();
126     processTo = in.readShort();
127   }
128
129   /**
130    * @see Externalizable#writeExternal(ObjectOutput)
131    */

132   public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
133   {
134     out.writeShort(processFrom);
135     out.writeShort(processTo);
136   }
137
138 }
Popular Tags