First more-or-less working version: does terms, booleans, qualifiers
[cql-java-moved-to-github.git] / src / org / z3950 / zing / cql / CQLNode.java
1 // $Id: CQLNode.java,v 1.5 2002-10-27 00:46:25 mike Exp $
2
3 package org.z3950.zing.cql;
4
5
6 /**
7  * Represents a node in a CQL parse-tree ...
8  * ###
9  *
10  * @version     $Id: CQLNode.java,v 1.5 2002-10-27 00:46:25 mike Exp $
11  */
12 public abstract class CQLNode {
13     abstract String toXCQL(int level);
14     abstract String toCQL();
15
16     protected String indent(int level) {
17         String x = "";
18         while (level-- > 0) {
19             x += "  ";
20         }
21         return x;
22     }
23
24     protected String xq(String str) {
25         // XML Quote
26         // ###  s/&/&/g;
27         //      s/</&lt;/g;
28         //      s/>/&gt;/g;
29         return str;
30     }
31
32     // Test harness
33     public static void main (String[] args) {
34         CQLNode n1 = new CQLTermNode("dc.author", "=", "kernighan");
35         CQLNode n2 = new CQLTermNode("dc.title", "all", "elements style");
36         CQLNode root = new CQLAndNode(n1, n2);
37         System.out.println(root.toXCQL(0));
38     }
39 }