1 // $Id: CQLNode.java,v 1.12 2002-11-06 20:13:45 mike Exp $
3 package org.z3950.zing.cql;
4 import java.util.Properties;
8 * Represents a node in a CQL parse-tree.
10 * @version $Id: CQLNode.java,v 1.12 2002-11-06 20:13:45 mike Exp $
12 public abstract class CQLNode {
13 CQLNode() {} // prevent javadoc from documenting this
16 * Translates a parse-tree into an XCQL document.
19 * The number of levels to indent the top element of the XCQL
20 * document. This will typically be 0 when invoked by an
21 * application; it takes higher values when this method is
22 * invoked recursively for nodes further down the tree.
24 * A String containing an XCQL document equivalent to the
25 * parse-tree whose root is this node.
27 abstract public String toXCQL(int level);
30 * Decompiles a parse-tree into a CQL query.
33 * A String containing a CQL query equivalent to the parse-tree
34 * whose root is this node, so that compiling that query will
35 * yield an identical tree.
37 abstract public String toCQL();
40 * Renders a parse-tree into a Yaz-style PQF string.
43 query ::= top-set query-struct.
44 top-set ::= [ '@attrset' string ]
45 query-struct ::= attr-spec | simple | complex | '@term' term-type
46 attr-spec ::= '@attr' [ string ] string query-struct
47 complex ::= operator query-struct query-struct.
48 operator ::= '@and' | '@or' | '@not' | '@prox' proximity.
49 simple ::= result-set | term.
50 result-set ::= '@set' string.
52 proximity ::= exclusion distance ordered relation which-code unit-code.
53 exclusion ::= '1' | '0' | 'void'.
55 ordered ::= '1' | '0'.
57 which-code ::= 'known' | 'private' | integer.
58 unit-code ::= integer.
59 term-type ::= 'general' | 'numeric' | 'string' | 'oid' | 'datetime' | 'null'.
62 * A String containing a PQF query equivalent to the parse-tree
63 * whose root is this node. This may be fed into the tool of
64 * your choice to obtain a BER-encoded packet.
66 abstract public String toPQF(Properties config)
67 throws PQFTranslationException;
70 * Returns a String of spaces for indenting to the specified level.
72 protected static String indent(int level) { return Utils.indent(level); }
75 * Returns the argument String quoted for XML.
76 * For example, each occurrence of <TT><</TT> is translated to
79 protected static String xq(String str) { return Utils.xq(str); }