lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mharw...@apache.org
Subject svn commit: r595996 - /lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
Date Sat, 17 Nov 2007 20:08:06 GMT
Author: mharwood
Date: Sat Nov 17 12:08:06 2007
New Revision: 595996

URL: http://svn.apache.org/viewvc?rev=595996&view=rev
Log:
Added toString implementation on BooleanFilter.java, provided by Jason Calabrese 

Modified:
    lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java

Modified: lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java?rev=595996&r1=595995&r2=595996&view=diff
==============================================================================
--- lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
(original)
+++ lucene/java/trunk/contrib/queries/src/java/org/apache/lucene/search/BooleanFilter.java
Sat Nov 17 12:08:06 2007
@@ -178,4 +178,43 @@
 		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(' ');
+			}
+		}
+	}		
 }



Mime
View raw message