1 21 package com.db4o.inside.mapping; 22 23 import com.db4o.*; 24 import com.db4o.foundation.*; 25 import com.db4o.inside.ix.*; 26 27 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 comparableObject(Transaction trans, Object 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 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 obj) { 59 MappedIDPair mappedIDs=(MappedIDPair)obj; 60 _origHandler.writeIndexEntry(reader, new Integer (mappedIDs.orig())); 61 _mappedHandler.writeIndexEntry(reader, new Integer (mappedIDs.mapped())); 62 } 63 64 public int compareTo(Object obj) { 65 return _origHandler.compareTo(((MappedIDPair)obj).orig()); 66 } 67 68 public Object current() { 69 return new MappedIDPair(_origHandler.currentInt(),_mappedHandler.currentInt()); 70 } 71 72 public boolean isEqual(Object obj) { 73 throw new NotImplementedException(); 74 } 75 76 public boolean isGreater(Object obj) { 77 throw new NotImplementedException(); 78 } 79 80 public boolean isSmaller(Object obj) { 81 throw new NotImplementedException(); 82 } 83 84 public YapComparable prepareComparison(Object 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 )_origHandler.readIndexEntry(a_reader)).intValue(); 93 } 94 } 95 | Popular Tags |