KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > bind > serial > test > NullClassCatalog


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: NullClassCatalog.java,v 1.17 2006/10/30 21:14:36 bostic Exp $
7  */

8
9 package com.sleepycat.bind.serial.test;
10
11 import java.io.ObjectStreamClass JavaDoc;
12 import java.math.BigInteger JavaDoc;
13
14 import com.sleepycat.je.DatabaseException;
15 import com.sleepycat.bind.serial.ClassCatalog;
16
17 /**
18  * NullCatalog is a dummy Catalog implementation that simply
19  * returns large (8 byte) class IDs so that ObjectOutput
20  * can be simulated when computing a serialized size.
21  *
22  * @author Mark Hayes
23  */

24 class NullClassCatalog implements ClassCatalog {
25
26     private long id = Long.MAX_VALUE;
27
28     public void close()
29         throws DatabaseException {
30     }
31
32     public byte[] getClassID(ObjectStreamClass JavaDoc classFormat)
33         throws DatabaseException {
34
35         return BigInteger.valueOf(id--).toByteArray();
36     }
37
38     public ObjectStreamClass JavaDoc getClassFormat(byte[] classID)
39         throws DatabaseException, ClassNotFoundException JavaDoc {
40
41         return null; // ObjectInput not supported
42
}
43 }
44
Popular Tags