lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r156600 - in lucene/java/trunk/src: java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.jj test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
Date Wed, 09 Mar 2005 03:21:24 GMT
Author: ehatcher
Date: Tue Mar  8 19:21:22 2005
New Revision: 156600

URL: http://svn.apache.org/viewcvs?view=rev&rev=156600
Log:
remove pesky static parse method that stymies flexibility

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java
    lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.jj
    lucene/java/trunk/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java?view=diff&r1=156599&r2=156600
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java
(original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.java
Tue Mar  8 19:21:22 2005
@@ -85,18 +85,6 @@
     static final Operator AND = new Operator("AND");
   }
 
-  /** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
-   *  @param expression  the query expression to be parsed.
-   *  @param field  the default field for query terms.
-   *  @param analyzer   used to find terms in the query text.
-   *  @throws ParseException if the parsing fails
-   */
-  static public Query parse(String expression, String field, Analyzer analyzer)
-       throws ParseException {
-    PrecedenceQueryParser parser = new PrecedenceQueryParser(field, analyzer);
-    return parser.parse(expression);
-  }
-
   /** Constructs a query parser.
    *  @param f  the default field for query terms.
    *  @param a   used to find terms in the query text.

Modified: lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.jj
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.jj?view=diff&r1=156599&r2=156600
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.jj
(original)
+++ lucene/java/trunk/src/java/org/apache/lucene/queryParser/precedence/PrecedenceQueryParser.jj
Tue Mar  8 19:21:22 2005
@@ -108,18 +108,6 @@
     static final Operator AND = new Operator("AND");
   }
 
-  /** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
-   *  @param expression  the query expression to be parsed.
-   *  @param field  the default field for query terms.
-   *  @param analyzer   used to find terms in the query text.
-   *  @throws ParseException if the parsing fails
-   */
-  static public Query parse(String expression, String field, Analyzer analyzer)
-       throws ParseException {
-    PrecedenceQueryParser parser = new PrecedenceQueryParser(field, analyzer);
-    return parser.parse(expression);
-  }
-
   /** Constructs a query parser.
    *  @param f  the default field for query terms.
    *  @param a   used to find terms in the query text.

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java?view=diff&r1=156599&r2=156600
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
(original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
Tue Mar  8 19:21:22 2005
@@ -223,7 +223,7 @@
 
     assertQueryEquals("a OR !b", null, "a (-b)");
     assertQueryEquals("a OR ! b", null, "a (-b)");
-    assertQueryEquals("a OR -b", null, "a (-b)");    
+    assertQueryEquals("a OR -b", null, "a (-b)");
   }
 
   public void testPunct() throws Exception {
@@ -488,7 +488,7 @@
     q = qp.parse("\"on\"^1.0");
     assertNotNull(q);
 
-    q = PrecedenceQueryParser.parse("the^3", "field", new StandardAnalyzer());
+    q = getParser(new StandardAnalyzer()).parse("the^3");
     assertNotNull(q);
   }
 
@@ -521,7 +521,7 @@
   public void testBooleanQuery() throws Exception {
     BooleanQuery.setMaxClauseCount(2);
     try {
-      PrecedenceQueryParser.parse("one two three", "field", new WhitespaceAnalyzer());
+      getParser(new WhitespaceAnalyzer()).parse("one two three");
       fail("ParseException expected due to too many boolean clauses");
     } catch (ParseException expected) {
       // too many boolean clauses, so ParseException is expected
@@ -533,28 +533,29 @@
    * precedence issue has been corrected.
    */
   public void testPrecedence() throws Exception {
-    Query query1 = PrecedenceQueryParser.parse("A AND B OR C AND D", "field", new WhitespaceAnalyzer());
-    Query query2 = PrecedenceQueryParser.parse("(A AND B) OR (C AND D)", "field", new WhitespaceAnalyzer());
+    PrecedenceQueryParser parser = getParser(new WhitespaceAnalyzer());
+    Query query1 = parser.parse("A AND B OR C AND D");
+    Query query2 = parser.parse("(A AND B) OR (C AND D)");
     assertEquals(query1, query2);
 
-    query1 = PrecedenceQueryParser.parse("A OR B C", "field", new WhitespaceAnalyzer());
-    query2 = PrecedenceQueryParser.parse("A B C", "field", new WhitespaceAnalyzer());
+    query1 = parser.parse("A OR B C");
+    query2 = parser.parse("A B C");
     assertEquals(query1, query2);
 
-    query1 = PrecedenceQueryParser.parse("A AND B C", "field", new WhitespaceAnalyzer());
-    query2 = PrecedenceQueryParser.parse("(+A +B) C", "field", new WhitespaceAnalyzer());
+    query1 = parser.parse("A AND B C");
+    query2 = parser.parse("(+A +B) C");
     assertEquals(query1, query2);
 
-    query1 = PrecedenceQueryParser.parse("A AND NOT B", "field", new WhitespaceAnalyzer());
-    query2 = PrecedenceQueryParser.parse("+A -B", "field", new WhitespaceAnalyzer());
+    query1 = parser.parse("A AND NOT B");
+    query2 = parser.parse("+A -B");
     assertEquals(query1, query2);
 
-    query1 = PrecedenceQueryParser.parse("A OR NOT B", "field", new WhitespaceAnalyzer());
-    query2 = PrecedenceQueryParser.parse("A -B", "field", new WhitespaceAnalyzer());
+    query1 = parser.parse("A OR NOT B");
+    query2 = parser.parse("A -B");
     assertEquals(query1, query2);
 
-    query1 = PrecedenceQueryParser.parse("A OR NOT B AND C", "field", new WhitespaceAnalyzer());
-    query2 = PrecedenceQueryParser.parse("A (-B +C)", "field", new WhitespaceAnalyzer());
+    query1 = parser.parse("A OR NOT B AND C");
+    query2 = parser.parse("A (-B +C)");
     assertEquals(query1, query2);
   }
 



Mime
View raw message