Fix test-harnesses and generator to work with new relation structure.
[cql-java-moved-to-github.git] / src / org / z3950 / zing / cql / CQLNode.java
index 3d16a37..5d731b7 100644 (file)
@@ -1,13 +1,13 @@
-// $Id: CQLNode.java,v 1.6 2002-10-29 10:15:58 mike Exp $
+// $Id: CQLNode.java,v 1.8 2002-10-30 11:13:18 mike Exp $
 
 package org.z3950.zing.cql;
 
 
 /**
- * Represents a node in a CQL parse-tree ...
+ * Represents a node in a CQL parse-tree.
  * ###
  *
- * @version    $Id: CQLNode.java,v 1.6 2002-10-29 10:15:58 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);
@@ -35,7 +35,8 @@ public abstract class CQLNode {
        return str;
     }
 
-    String replace(String str, String from, String to) {
+    // I can't _believe_ I have to write this by hand in 2002 ...
+    protected static String replace(String str, String from, String to) {
        StringBuffer sb = new StringBuffer();
        int ix;                 // index of next `from'
        int offset = 0;         // index of previous `from' + length(from)
@@ -53,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));
     }