KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > inside > ix > IxAdd


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.inside.ix;
22
23 import com.db4o.*;
24 import com.db4o.foundation.*;
25 import com.db4o.inside.freespace.*;
26
27 /**
28  * An addition to a field index.
29  */

30 public class IxAdd extends IxPatch {
31     
32     boolean _keepRemoved;
33
34     public IxAdd(IndexTransaction a_ft, int a_parentID, Object JavaDoc a_value) {
35         super(a_ft, a_parentID, a_value);
36     }
37     
38     void beginMerge(){
39         super.beginMerge();
40         handler().prepareComparison( handler().comparableObject(trans(), _value));
41     }
42     
43     public void visit(Object JavaDoc obj){
44         ((Visitor4)obj).visit(new Integer JavaDoc(_parentID));
45     }
46     
47     public void visit(Visitor4 visitor, int[] lowerAndUpperMatch){
48         visitor.visit(new Integer JavaDoc(_parentID));
49     }
50     
51     public void freespaceVisit(FreespaceVisitor visitor, int index){
52         visitor.visit(_parentID, ((Integer JavaDoc)_value).intValue());
53     }
54     
55     public int write(Indexable4 a_handler, YapWriter a_writer) {
56         a_handler.writeIndexEntry(a_writer, _value);
57         a_writer.writeInt(_parentID);
58         a_writer.writeForward();
59         return 1;
60     }
61     
62     public String JavaDoc toString(){
63         if(! Debug4.prettyToStrings){
64             return super.toString();
65         }
66         String JavaDoc str = "IxAdd " + _parentID + "\n " + handler().comparableObject(trans(), _value);
67         return str;
68     }
69
70     public void visitAll(IntObjectVisitor visitor) {
71         visitor.visit(_parentID, handler().comparableObject(trans(), _value));
72     }
73
74     public Object JavaDoc shallowClone() {
75         IxAdd add=new IxAdd(_fieldTransaction,_parentID,_value);
76         super.shallowCloneInternal(add);
77         add._keepRemoved=_keepRemoved;
78         return add;
79     }
80 }
81
Popular Tags