KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > storage > gammaStore > NodeIdLoc


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// Copyright (C) 2003-@year@, Leo Mekenkamp. All rights reserved.
5
//
6
// $Id: NodeIdLoc.java,v 1.2 2004/01/25 20:53:42 leomekenkamp Exp $
7

8 package org.ozoneDB.core.storage.gammaStore;
9
10 import java.io.Serializable JavaDoc;
11
12 /**
13  * @author <a HREF="mailto:leoATmekenkampD0Tcom">Leo Mekenkamp (mind the anti sp@m)</a>
14  * @version $Id: NodeIdLoc.java,v 1.2 2004/01/25 20:53:42 leomekenkamp Exp $
15  */

16 public class NodeIdLoc extends Loc {
17     
18     protected long[] nodeIds;
19     
20     public NodeIdLoc(int capacity, float bufferFactor) {
21         super(capacity, bufferFactor);
22         nodeIds = new long[keys.length];
23     }
24
25     public NodeIdLoc(int capacity, int slack) {
26         super(capacity, slack);
27         nodeIds = new long[keys.length];
28     }
29
30     public void putNodeId(int pos, long nodeId) {
31         nodeIds[pos] = nodeId;
32     }
33     
34     protected void move(int from, int to) {
35         super.move(from, to);
36         nodeIds[to] = nodeIds[from];
37     }
38     
39     public long getNodeId(int pos) {
40         return nodeIds[pos];
41     }
42
43     public String JavaDoc toString() {
44         StringBuffer JavaDoc result = new StringBuffer JavaDoc(super.toString());
45         result.append(" nodes [");
46         for (int i = 0; i < nodeIds.length; i++) {
47             result.append(nodeIds[i]);
48             if (!isInUse(i)) {
49                 result.append("D");
50             }
51             if (i < nodeIds.length - 1) {
52                 result.append(", ");
53             } else {
54                 result.append("]");
55             }
56         }
57         
58         return result.toString();
59     }
60     
61 }
62
Popular Tags