1 2 12 package com.versant.core.jdo.query.mem; 13 14 import com.versant.core.common.OID; 15 16 import java.util.List ; 17 import java.util.Comparator ; 18 import java.util.Collections ; 19 20 import com.versant.core.common.OID; 21 import com.versant.core.jdo.PMProxy; 22 import com.versant.core.jdo.VersantPersistenceManagerImp; 23 24 27 public class BCodeSorter implements Comparator { 28 private List toSort; 29 private PMProxy pmProxy; 30 private BCodeQuery bCodeCompare; 31 32 public void sort(List listOfOids, PMProxy pmProxy, BCodeQuery bCodeCompare) { 33 this.toSort = listOfOids; 34 this.pmProxy = pmProxy; 35 this.bCodeCompare = bCodeCompare; 36 Collections.sort(toSort, this); 37 } 38 39 public int compare(Object o1, Object o2) { 40 return compare((OID) o1, (OID) o2); 41 } 42 43 49 public int compare(OID o1, OID o2) { 50 int comp = 0; 51 try { 52 final VersantPersistenceManagerImp realPM = pmProxy.getRealPM(); 53 comp = bCodeCompare.compare(realPM.getInternalSM(o1).queryStateWrapper, 54 realPM.getInternalSM(o2).queryStateWrapper); 55 } catch (Exception e) { 56 comp = -1; 57 } 58 return comp; 59 } 60 } 61 62 63 | Popular Tags |