1 package org.apache.lucene.search.highlight; 2 17 18 19 22 public class TextFragment 23 { 24 StringBuffer markedUpText; 25 int fragNum; 26 int textStartPos; 27 int textEndPos; 28 float score; 29 30 public TextFragment(StringBuffer markedUpText,int textStartPos, int fragNum) 31 { 32 this.markedUpText=markedUpText; 33 this.textStartPos = textStartPos; 34 this.fragNum = fragNum; 35 } 36 40 void setScore(float score) 41 { 42 this.score=score; 43 } 44 48 public float getScore() 49 { 50 return score; 51 } 52 55 public void merge(TextFragment frag2) 56 { 57 textEndPos = frag2.textEndPos; 58 score=Math.max(score,frag2.score); 59 } 60 64 public boolean follows(TextFragment fragment) 65 { 66 return textStartPos == fragment.textEndPos; 67 } 68 69 73 public int getFragNum() 74 { 75 return fragNum; 76 } 77 78 80 public String toString() { 81 return markedUpText.substring(textStartPos, textEndPos); 82 } 83 84 } 85 | Popular Tags |