KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > io > serializer > impl > ObjectIDSerializer


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.io.serializer.impl;
5
6 import com.tc.io.serializer.api.Serializer;
7 import com.tc.object.ObjectID;
8
9 import java.io.IOException JavaDoc;
10 import java.io.ObjectInput JavaDoc;
11 import java.io.ObjectOutput JavaDoc;
12
13 /**
14  * ObjectIDs
15  */

16 public final class ObjectIDSerializer implements Serializer {
17
18   public void serializeTo(Object JavaDoc o, ObjectOutput JavaDoc out) throws IOException JavaDoc {
19     out.writeLong(((ObjectID) o).toLong());
20   }
21
22   public Object JavaDoc deserializeFrom(ObjectInput JavaDoc in) throws IOException JavaDoc {
23     return new ObjectID(in.readLong());
24   }
25
26   public byte getSerializerID() {
27     return OBJECT_ID;
28   }
29 }
Popular Tags