1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.common; 2 3 import java.util.ArrayList ; 4 import java.util.HashMap ; 5 import com.daffodilwoods.fulltext.common._Token; 6 import com.daffodilwoods.daffodildb.utils.GetByteComparator; 7 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator; 8 import com.daffodilwoods.daffodildb.utils.field.FieldBase; 9 import com.daffodilwoods.database.resource.*; 10 import com.daffodilwoods.database.utility.P; 11 12 21 public class ByteToken implements _Token,Comparable { 22 FieldBase term; 23 long[] location; 24 SuperComparator comp = GetByteComparator.stringComparator; 25 26 27 public ByteToken(Object term, long loc) { 28 this.term = (FieldBase)term; 29 location = new long[]{loc}; 30 } 31 35 public long[] getLocation() { 36 return location; 37 } 38 42 public Object getTerm() { 43 return term; 44 } 45 46 49 50 public void addLocation(long[] loc) { 51 long[] temp = new long[location.length+loc.length]; 52 System.arraycopy(location,0,temp,0,location.length); 53 System.arraycopy(loc,0,temp,location.length,loc.length); 54 location = temp; 55 } 56 57 public int compareTo(Object o){ 58 try { 59 return comp.compare(term,((ByteToken)o).getTerm()); 60 } 61 catch (DException ex) { 62 throw new RuntimeException (ex.getMessage()); 63 } 64 } 65 66 public String toString(){ 67 Object obj = null; 68 try { 69 obj = term.getObject(); 70 } 71 catch (DException ex) { 72 throw new RuntimeException (ex.getMessage()); 73 } 74 String t = obj instanceof byte[] ? new String ((byte[])obj) : obj.toString(); 75 return "ByteTokenizer[term = "+t+" Location = "+P.print(location)+"]"; 76 } 77 78 79 } 80 | Popular Tags |