Added toString implementation on BooleanFilter.java, provided by Jason Calabrese

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@595996 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Harwood 2007-11-17 20:08:06 +00:00
parent e35a66d8a3
commit 04ae927f38
1 changed files with 39 additions and 0 deletions

View File

@ -178,4 +178,43 @@ public class BooleanFilter extends Filter
return hash;
}
/** Prints a user-readable version of this query. */
public String toString()
{
StringBuffer buffer = new StringBuffer();
buffer.append("BooleanFilter(");
appendFilters(shouldFilters, null, buffer);
appendFilters(mustFilters, "+", buffer);
appendFilters(notFilters, "-", buffer);
buffer.append(")");
return buffer.toString();
}
private void appendFilters(ArrayList filters, String occurString,
StringBuffer buffer)
{
if (filters == null)
return;
for (int i = 0; i < filters.size(); i++)
{
Filter filter = (Filter) filters.get(i);
if (occurString != null)
{
buffer.append(occurString);
}
buffer.append(filter);
if (i < filters.size() - 1)
{
buffer.append(' ');
}
}
}
}