1 package org.apache.lucene.search.highlight; 2 17 18 23 public class SimpleHTMLFormatter implements Formatter 24 { 25 String preTag; 26 String postTag; 27 28 29 public SimpleHTMLFormatter(String preTag, String postTag) 30 { 31 this.preTag = preTag; 32 this.postTag = postTag; 33 } 34 35 39 public SimpleHTMLFormatter() 40 { 41 this.preTag = "<B>"; 42 this.postTag = "</B>"; 43 } 44 45 48 public String highlightTerm(String originalText, TokenGroup tokenGroup) 49 { 50 StringBuffer returnBuffer; 51 if(tokenGroup.getTotalScore()>0) 52 { 53 returnBuffer=new StringBuffer (); 54 returnBuffer.append(preTag); 55 returnBuffer.append(originalText); 56 returnBuffer.append(postTag); 57 return returnBuffer.toString(); 58 } 59 return originalText; 60 } 61 } 62 | Popular Tags |