print(mTemplate);
}
private void initializeHighlighting() throws EngineException
{
Query query = null;
mSearchBean = (Search.SearchBean)getNamedInputBean("SearchBean");
if (mSearchBean != null &&
mSearchBean.getKeyword() != null &&
!mSearchBean.getKeyword().equals(""))
{
try
{
query = QueryParser.parse(mSearchBean.getKeyword(), "message", new StandardAnalyzer());
}
catch (org.apache.lucene.queryParser.ParseException e)
{
// just ignore it, nothing I can do
}
}
if (query != null)
{
try
{
Collection bots = BotsRunner.getRepInstance().getBots();
Iterator iter = bots.iterator();
String readerDir = null;
while (iter.hasNext())
{
Bot bot = (Bot)iter.next();
if (bot.getName().equals(getInput("botname")))
{
StringBuffer key = new StringBuffer();
key
.append(Config.getRepInstance().getString("LUCENE_DIR"))
.append(File.separator)
.append(bot.getName())
.append("-")
.append(bot.getServer().getServerName())
.append("-")
.append(getInput("channelname").substring(1));
readerDir = key.toString();
}
}
if (readerDir != null)
{
IndexReader reader = IndexReader.open(readerDir);
SimpleHTMLFormatter formatter = new SimpleHTMLFormatter("<span class=\"highlighted\">", "</span>");
mHighlighter = new Highlighter(formatter, new QueryScorer(query.rewrite(reader)));
}
else
{
throw new IOException("Couldn't find the correct index directory for this bot, channel, and server combination");
}