KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > P1HashElement


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10 Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11 Suite 350, San Mateo, CA 94403, USA.
12
13 db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

21 package com.db4o;
22
23 /**
24  * @exclude
25  * @persistent
26  */

27 public class P1HashElement extends P1ListElement {
28     
29     public Object JavaDoc i_key;
30     public int i_hashCode;
31     public int i_position;
32     
33     public P1HashElement(){
34     }
35     
36     public P1HashElement(Transaction a_trans, P1ListElement a_next, Object JavaDoc a_key, int a_hashCode, Object JavaDoc a_object){
37         super(a_trans, a_next, a_object);
38         i_hashCode = a_hashCode;
39         i_key = a_key;
40     }
41     
42     public int adjustReadDepth(int a_depth) {
43         return 1;
44     }
45     
46     Object JavaDoc activatedKey(int a_depth){
47         
48         // TODO: It may be possible to optimise away the following call.
49
checkActive();
50
51         
52         // The pathologic case here:
53
// No activation depth for the map.
54
// Global activation depth of 0 during defragment
55
// The key can't activate at all.
56

57         // Let's make sure it has a depth of 1 at least, but of course that
58
// may not be sufficient for more complex #hashCode calls.
59
if(a_depth < 0){
60             Transaction trans = getTrans();
61             if(trans != null){
62                 if(trans.stream().configImpl().activationDepth() < 1){
63                     a_depth = 1;
64                 }
65             }
66         }
67         
68         activate(i_key, a_depth);
69         return i_key;
70     }
71     
72     void delete(boolean a_deleteRemoved){
73         if(a_deleteRemoved){
74             delete(i_key);
75         }
76         super.delete(a_deleteRemoved);
77     }
78 }
79
Popular Tags