X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Forg%2Fz3950%2Fzing%2Fcql%2FCQLBooleanNode.java;h=b0ca761d8d0414df3c5bc2101d049874ba83a79c;hb=d524fe097f11c7ab8a16ac98e1dedd3a3e24c993;hp=489e39b1266648070f7ec2f60a06f27a739206a6;hpb=70be8275aabe87c909bf11148bb279c3e1380bb2;p=cql-java-moved-to-github.git diff --git a/src/org/z3950/zing/cql/CQLBooleanNode.java b/src/org/z3950/zing/cql/CQLBooleanNode.java index 489e39b..b0ca761 100644 --- a/src/org/z3950/zing/cql/CQLBooleanNode.java +++ b/src/org/z3950/zing/cql/CQLBooleanNode.java @@ -1,30 +1,55 @@ -// $Id: CQLBooleanNode.java,v 1.5 2002-10-30 09:19:26 mike Exp $ +// $Id: CQLBooleanNode.java,v 1.8 2002-11-06 20:13:45 mike Exp $ package org.z3950.zing.cql; +import java.util.Properties; /** * Represents a boolean node in a CQL parse-tree. - * ### * - * @version $Id: CQLBooleanNode.java,v 1.5 2002-10-30 09:19:26 mike Exp $ + * @version $Id: CQLBooleanNode.java,v 1.8 2002-11-06 20:13:45 mike Exp $ */ public abstract class CQLBooleanNode extends CQLNode { - protected CQLNode left; - protected CQLNode right; + CQLBooleanNode() {} // prevent javadoc from documenting this - abstract String op(); + /** + * The root of a parse-tree representing the left-hand side. + */ + public CQLNode left; + + /** + * The root of a parse-tree representing the right-hand side. + */ + public CQLNode right; - String toXCQL(int level) { + public String toXCQL(int level) { return (indent(level) + "\n" + - indent(level+1) + "" + op() + "\n" + + opXQL(level+1) + left.toXCQL(level+1) + right.toXCQL(level+1) + indent(level) + "\n"); } - String toCQL() { + // Represents the boolean operation itself: overridden for CQLProxNode + String opXQL(int level) { + return(indent(level) + "\n" + + indent(level+1) + "" + op() + "\n" + + indent(level) + "\n"); + } + + public String toCQL() { // ### We don't always need parens around the operands return "(" + left.toCQL() + ") " + op() + " (" + right.toCQL() + ")"; } + + public String toPQF(Properties config) throws PQFTranslationException { + return ("@" + opPQF() + + " " + left.toPQF(config) + + " " + right.toPQF(config)); + } + + // represents the operation for PQF: overridden for CQLProxNode + String opPQF() { return op(); } + + abstract String op(); }