1 package org.apache.lucene.index; 2 3 18 19 26 27 public final class Term implements Comparable , java.io.Serializable { 28 String field; 29 String text; 30 31 32 public Term(String fld, String txt) { 33 this(fld, txt, true); 34 } 35 Term(String fld, String txt, boolean intern) { 36 field = intern ? fld.intern() : fld; text = txt; } 39 40 42 public final String field() { return field; } 43 44 47 public final String text() { return text; } 48 49 55 public Term createTerm(String text) 56 { 57 return new Term(field,text,false); 58 } 59 60 62 public final boolean equals(Object o) { 63 if (o == null) 64 return false; 65 Term other = (Term)o; 66 return field == other.field && text.equals(other.text); 67 } 68 69 70 public final int hashCode() { 71 return field.hashCode() + text.hashCode(); 72 } 73 74 public int compareTo(Object other) { 75 return compareTo((Term)other); 76 } 77 78 83 public final int compareTo(Term other) { 84 if (field == other.field) return text.compareTo(other.text); 86 else 87 return field.compareTo(other.field); 88 } 89 90 91 final void set(String fld, String txt) { 92 field = fld; 93 text = txt; 94 } 95 96 public final String toString() { return field + ":" + text; } 97 98 private void readObject(java.io.ObjectInputStream in) 99 throws java.io.IOException , ClassNotFoundException 100 { 101 in.defaultReadObject(); 102 field = field.intern(); 103 } 104 } 105 | Popular Tags |