KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > inside > mapping > MappedIDPairHandler


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.mapping;
22
23 import com.db4o.*;
24 import com.db4o.foundation.*;
25 import com.db4o.inside.ix.*;
26
27 /**
28  * @exclude
29  */

30 public class MappedIDPairHandler implements Indexable4 {
31
32     private final YInt _origHandler;
33     private final YInt _mappedHandler;
34     
35     public MappedIDPairHandler(YapStream stream) {
36         _origHandler=new YInt(stream);
37         _mappedHandler=new YInt(stream);
38     }
39
40     public Object JavaDoc comparableObject(Transaction trans, Object JavaDoc indexEntry) {
41         throw new NotImplementedException();
42     }
43
44     public void defragIndexEntry(ReaderPair readers) {
45         throw new NotImplementedException();
46     }
47
48     public int linkLength() {
49         return _origHandler.linkLength()+_mappedHandler.linkLength();
50     }
51
52     public Object JavaDoc readIndexEntry(YapReader reader) {
53         int origID=readID(reader);
54         int mappedID=readID(reader);
55         return new MappedIDPair(origID,mappedID);
56     }
57
58     public void writeIndexEntry(YapReader reader, Object JavaDoc obj) {
59         MappedIDPair mappedIDs=(MappedIDPair)obj;
60         _origHandler.writeIndexEntry(reader, new Integer JavaDoc(mappedIDs.orig()));
61         _mappedHandler.writeIndexEntry(reader, new Integer JavaDoc(mappedIDs.mapped()));
62     }
63
64     public int compareTo(Object JavaDoc obj) {
65         return _origHandler.compareTo(((MappedIDPair)obj).orig());
66     }
67
68     public Object JavaDoc current() {
69         return new MappedIDPair(_origHandler.currentInt(),_mappedHandler.currentInt());
70     }
71
72     public boolean isEqual(Object JavaDoc obj) {
73         throw new NotImplementedException();
74     }
75
76     public boolean isGreater(Object JavaDoc obj) {
77         throw new NotImplementedException();
78     }
79
80     public boolean isSmaller(Object JavaDoc obj) {
81         throw new NotImplementedException();
82     }
83
84     public YapComparable prepareComparison(Object JavaDoc obj) {
85         MappedIDPair mappedIDs = (MappedIDPair)obj;
86         _origHandler.prepareComparison(mappedIDs.orig());
87         _mappedHandler.prepareComparison(mappedIDs.mapped());
88         return this;
89     }
90     
91     private int readID(YapReader a_reader) {
92         return ((Integer JavaDoc)_origHandler.readIndexEntry(a_reader)).intValue();
93     }
94 }
95
Popular Tags