01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: 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: import com.db4o.internal.*;
24:
25: /**
26: * @exclude
27: * @persistent
28: */
29: public class P1HashElement extends P1ListElement {
30:
31: public Object i_key;
32: public int i_hashCode;
33: public int i_position;
34:
35: public P1HashElement() {
36: }
37:
38: public P1HashElement(Transaction a_trans, P1ListElement a_next,
39: Object a_key, int a_hashCode, Object a_object) {
40: super (a_trans, a_next, a_object);
41: i_hashCode = a_hashCode;
42: i_key = a_key;
43: }
44:
45: public int adjustReadDepth(int a_depth) {
46: return 1;
47: }
48:
49: Object activatedKey(int a_depth) {
50:
51: // TODO: It may be possible to optimise away the following call.
52: checkActive();
53:
54: // The pathologic case here:
55: // No activation depth for the map.
56: // Global activation depth of 0 during defragment
57: // The key can't activate at all.
58:
59: // Let's make sure it has a depth of 1 at least, but of course that
60: // may not be sufficient for more complex #hashCode calls.
61: if (a_depth < 0) {
62: Transaction trans = getTrans();
63: if (trans != null) {
64: if (trans.container().configImpl().activationDepth() < 1) {
65: a_depth = 1;
66: }
67: }
68: }
69:
70: activate(i_key, a_depth);
71: return i_key;
72: }
73:
74: void delete(boolean a_deleteRemoved) {
75: if (a_deleteRemoved) {
76: delete(i_key);
77: }
78: super.delete(a_deleteRemoved);
79: }
80: }
|