X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Forg%2Fz3950%2Fzing%2Fcql%2FCQLNode.java;h=24a2d2746965ba0e32f6fff7e8ac572668c534ab;hb=df372083094087da8590a526e0222c81c9ae7fc0;hp=d36c11f559344c3bd7376aa1fd91dca1f6bb8654;hpb=d499738d2422e499fd7cb19c30b7d7fdee86e86d;p=cql-java-moved-to-github.git diff --git a/src/org/z3950/zing/cql/CQLNode.java b/src/org/z3950/zing/cql/CQLNode.java index d36c11f..24a2d27 100644 --- a/src/org/z3950/zing/cql/CQLNode.java +++ b/src/org/z3950/zing/cql/CQLNode.java @@ -1,31 +1,61 @@ -// $Id: CQLNode.java,v 1.10 2002-11-05 17:21:30 mike Exp $ +// $Id: CQLNode.java,v 1.11 2002-11-06 00:05:58 mike Exp $ package org.z3950.zing.cql; +import java.util.Properties; /** * Represents a node in a CQL parse-tree. - * ## * - * @version $Id: CQLNode.java,v 1.10 2002-11-05 17:21:30 mike Exp $ + * @version $Id: CQLNode.java,v 1.11 2002-11-06 00:05:58 mike Exp $ */ public abstract class CQLNode { + CQLNode() {} // prevent javadoc from documenting this + + /** + * Translates a parse-tree into an XCQL document. + *

+ * @param level + * The number of levels to indent the top element of the XCQL + * document. This will typically be 0 when invoked by an + * application; it takes higher values when this method is + * invoked recursively for nodes further down the tree. + * @return + * A String containing an XCQL document equivalent to the + * parse-tree whose root is this node. + */ abstract public String toXCQL(int level); + + /** + * Decompiles a parse-tree into a CQL query. + *

+ * @return + * A String containing a CQL query equivalent to the parse-tree + * whose root is this node, so that compiling that query will + * yield an identical tree. + */ abstract public String toCQL(); - // Utility-function abbreviations for the use of subclasses + /** + * Renders a parse-tree into a Yaz-style PQF string. + *

+ * @return + * A String containing a PQF query equivalent to the parse-tree + * whose root is this node. This may be fed into the tool of + * your choice to obtain a BER-encoded packet. + */ + abstract public String toPQF(Properties config) + throws UnknownQualifierException, UnknownRelationException; + + /** + * Returns a String of spaces for indenting to the specified level. + */ protected static String indent(int level) { return Utils.indent(level); } - protected static String xq(String str) { return Utils.xq(str); } - // Test harness - public static void main (String[] args) { - 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)); - } + /** + * Returns the argument String quoted for XML. + * For example, each occurrence of < is translated to + * &lt;. + */ + protected static String xq(String str) { return Utils.xq(str); } }