From: mike Date: Wed, 30 Oct 2002 11:13:18 +0000 (+0000) Subject: Fix test-harnesses and generator to work with new relation structure. X-Git-Tag: v1.5~253 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=caeab95a0bbe3a694746bb3244e6605c36927c1e;p=cql-java-moved-to-github.git Fix test-harnesses and generator to work with new relation structure. --- diff --git a/README b/README index e4e2320..590fff1 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -$Id: README,v 1.5 2002-10-30 09:19:26 mike Exp $ +$Id: README,v 1.6 2002-10-30 11:13:18 mike Exp $ cql-java -- a free CQL compiler for Java @@ -101,9 +101,9 @@ TO DO and running that through JZKit's existing PQN-to-Type-1 compiler. * Refinements to random query generator: - * Fix to handle new, structured, relation representation * Generate relation modifiers * Proximity support + * Don't always generate qualifier/relation for terms * Better selection of qualifier (configurable?) * Better selection of terms (from a dictionary file?) * Introduce wildcard characters into generated terms diff --git a/src/org/z3950/zing/cql/CQLGenerator.java b/src/org/z3950/zing/cql/CQLGenerator.java index bc732e2..67e70d1 100644 --- a/src/org/z3950/zing/cql/CQLGenerator.java +++ b/src/org/z3950/zing/cql/CQLGenerator.java @@ -1,4 +1,4 @@ -// $Id: CQLGenerator.java,v 1.1 2002-10-30 09:19:26 mike Exp $ +// $Id: CQLGenerator.java,v 1.2 2002-10-30 11:13:18 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -22,7 +22,7 @@ import java.io.FileNotFoundException; * this distribution - there is a generate_x() method * for each grammar element X. * - * @version $Id: CQLGenerator.java,v 1.1 2002-10-30 09:19:26 mike Exp $ + * @version $Id: CQLGenerator.java,v 1.2 2002-10-30 11:13:18 mike Exp $ * @see http://zing.z3950.org/cql/index.html */ @@ -154,8 +154,9 @@ public class CQLGenerator { return generate_cql_query(); } + // ### Should sometimes generate qualifier/relation-free terms String qualifier = generate_qualifier(); - String relation = generate_relation(); + CQLRelation relation = generate_relation(); String term = generate_term(); return new CQLTermNode(qualifier, relation, term); @@ -182,10 +183,11 @@ public class CQLGenerator { return qualifier; } - // ### Representation of relations will change when we handle modifiers - private String generate_relation() throws ParameterMissingException { - return generate_base_relation(); + private CQLRelation generate_relation() throws ParameterMissingException { + String base = generate_base_relation(); + CQLRelation rel = new CQLRelation(base); // ### should generate modifiers too + return rel; } private String generate_base_relation() throws ParameterMissingException { diff --git a/src/org/z3950/zing/cql/CQLNode.java b/src/org/z3950/zing/cql/CQLNode.java index 3267432..5d731b7 100644 --- a/src/org/z3950/zing/cql/CQLNode.java +++ b/src/org/z3950/zing/cql/CQLNode.java @@ -1,4 +1,4 @@ -// $Id: CQLNode.java,v 1.7 2002-10-30 09:19:26 mike Exp $ +// $Id: CQLNode.java,v 1.8 2002-10-30 11:13:18 mike Exp $ package org.z3950.zing.cql; @@ -7,7 +7,7 @@ package org.z3950.zing.cql; * Represents a node in a CQL parse-tree. * ### * - * @version $Id: CQLNode.java,v 1.7 2002-10-30 09:19:26 mike Exp $ + * @version $Id: CQLNode.java,v 1.8 2002-10-30 11:13:18 mike Exp $ */ public abstract class CQLNode { abstract String toXCQL(int level); @@ -54,8 +54,12 @@ public abstract class CQLNode { // Test harness public static void main (String[] args) { - CQLNode n1 = new CQLTermNode("dc.author", "=", "kernighan"); - CQLNode n2 = new CQLTermNode("dc.title", "all", "elements style"); + CQLNode n1 = new CQLTermNode("dc.author", + new CQLRelation("="), + "kernighan"); + CQLNode n2 = new CQLTermNode("dc.title", + new CQLRelation("all"), + "elements style"); CQLNode root = new CQLAndNode(n1, n2); System.out.println(root.toXCQL(0)); }