01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: IDTableNodeLeaf.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
08:
09: package org.ozoneDB.core.wizardStore;
10:
11: import java.io.*;
12: import org.ozoneDB.DxLib.*;
13: import org.ozoneDB.core.ObjectID;
14:
15: /**
16: * This extension of the DxDiskHashNodeLeaf class assumes that the key and data
17: * member of the stored DxKayData pairs are ObjectIDs. Thus is casts and writes
18: * them directly to the stream for better performance.
19: */
20: class IDTableNodeLeaf extends DxDiskHashNodeLeaf implements
21: Externalizable {
22:
23: final static long serialVersionUID = 1L;
24:
25: public IDTableNodeLeaf(DxDiskHashMap _grandParent) {
26: super (_grandParent);
27: }
28:
29: public void writeExternal(ObjectOutput out) throws IOException {
30: byte c = 0;
31: for (DxKeyData elem = element; elem != null; elem = elem.next) {
32: c++;
33: }
34: out.writeByte(c);
35:
36: DxKeyData elem = element;
37: while (elem != null) {
38: ((ObjectID) elem.key).writeExternal(out);
39: ((ObjectID) elem.data).writeExternal(out);
40: elem = elem.next;
41: }
42: }
43:
44: public void readExternal(ObjectInput in) throws IOException,
45: ClassNotFoundException {
46: byte c = in.readByte();
47:
48: ObjectID key = ((IDTable) grandParent).newObjectID();
49: key.readExternal(in);
50: ClusterID data = ((IDTable) grandParent).newClusterID();
51: data.readExternal(in);
52: element = grandParent.newKeyData();
53: element.set(key, data);
54:
55: DxKeyData elem = element;
56: for (int i = 1; i < c; i++) {
57: key = ((IDTable) grandParent).newObjectID();
58: key.readExternal(in);
59: data = ((IDTable) grandParent).newClusterID();
60: data.readExternal(in);
61: elem.next = ((IDTable) grandParent).newKeyData();
62: elem.next.set(key, data);
63: elem = elem.next;
64: }
65: }
66: }
|