KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > pushwithreturn > KeyChunkImpl


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.pushwithreturn;
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 import org.objectweb.dream.util.Util;
36
37 /**
38  * Basic implementation of the {@link KeyChunk}interface.
39  */

40 public class KeyChunkImpl extends AbstractChunk
41     implements
42       KeyChunk,
43       Externalizable JavaDoc
44 {
45   Key key = null;
46
47   // ---------------------------------------------------------------------------
48
// Implementation of the KeyChunk interface.
49
// ---------------------------------------------------------------------------
50

51   /**
52    * @see KeyChunk#getKey()
53    */

54   public Key getKey()
55   {
56     return key;
57   }
58
59   /**
60    * @see KeyChunk#setKey(Key)
61    */

62   public void setKey(Key key)
63   {
64     this.key = key;
65   }
66
67   // ---------------------------------------------------------------------------
68
// Implementation of the Chunk interface.
69
// ---------------------------------------------------------------------------
70
/**
71    * @see org.objectweb.dream.message.Chunk#getType()
72    */

73   public ChunkType getType()
74   {
75     return TYPE;
76   }
77
78   /**
79    * @see org.objectweb.dream.message.Chunk#transfertState(org.objectweb.dream.message.Chunk)
80    */

81   public void transfertState(Chunk newInstance)
82   {
83     ((KeyChunk) newInstance).setKey(getKey());
84   }
85
86   /**
87    * @see org.objectweb.dream.message.Chunk#recycle()
88    */

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

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

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

110   public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
111   {
112     Util.writeObject(out, key);
113   }
114
115 }
Popular Tags