X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Forg%2Fz3950%2Fzing%2Fcql%2FCQLBooleanNode.java;h=9462914e3b55602f6d04f8110e0bcdb179d2d8a9;hb=f57d48d060411f662eea823b97cc45038bda0def;hp=9679ec411a8949a234bd04cc6987855bd15e2d97;hpb=8a7980aa0d3ea84b199dce9daca42e6286efaa2a;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 9679ec4..9462914 100644
--- a/src/org/z3950/zing/cql/CQLBooleanNode.java
+++ b/src/org/z3950/zing/cql/CQLBooleanNode.java
@@ -1,4 +1,4 @@
-// $Id: CQLBooleanNode.java,v 1.10 2002-11-20 17:26:42 mike Exp $
+// $Id: CQLBooleanNode.java,v 1.17 2007-07-03 13:40:13 mike Exp $
package org.z3950.zing.cql;
import java.util.Properties;
@@ -8,11 +8,9 @@ import java.util.Vector;
/**
* Represents a boolean node in a CQL parse-tree.
*
- * @version $Id: CQLBooleanNode.java,v 1.10 2002-11-20 17:26:42 mike Exp $
+ * @version $Id: CQLBooleanNode.java,v 1.17 2007-07-03 13:40:13 mike Exp $
*/
public abstract class CQLBooleanNode extends CQLNode {
- CQLBooleanNode() {} // prevent javadoc from documenting this
-
/**
* The root of a parse-tree representing the left-hand side.
*/
@@ -23,30 +21,38 @@ public abstract class CQLBooleanNode extends CQLNode {
*/
public CQLNode right;
- public String toXCQL(int level, Vector prefixes) {
+ /**
+ * The set of modifiers that are applied to this boolean.
+ */
+ public ModifierSet ms;
+
+ protected CQLBooleanNode(CQLNode left, CQLNode right, ModifierSet ms) {
+ this.left = left;
+ this.right = right;
+ this.ms = ms;
+ }
+
+ public String toXCQL(int level, Vector prefixes, Vector sortkeys) {
+ if (sortkeys != null)
+ throw new Error("CQLBooleanNode.toXCQL() called with sortkeys");
+
return (indent(level) + "\n" +
renderPrefixes(level+1, prefixes) +
- opXCQL(level+1) +
+ ms.toXCQL(level+1, "boolean") +
indent(level+1) + "\n" +
- left.toXCQL(level+2, new Vector()) +
+ left.toXCQL(level+2) +
indent(level+1) + "\n" +
indent(level+1) + "\n" +
- right.toXCQL(level+2, new Vector()) +
+ right.toXCQL(level+2) +
indent(level+1) + "\n" +
indent(level) + "\n");
}
- // Represents the boolean operation itself: overridden for CQLProxNode
- String opXCQL(int level) {
- System.err.println("in CQLBooleanNode.opXCQL()");
- 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() + ")";
+ return ("(" + left.toCQL() + ")" +
+ " " + ms.toCQL() + " " +
+ "(" + right.toCQL() + ")");
}
public String toPQF(Properties config) throws PQFTranslationException {
@@ -56,7 +62,30 @@ public abstract class CQLBooleanNode extends CQLNode {
}
// represents the operation for PQF: overridden for CQLProxNode
- String opPQF() { return op(); }
+ String opPQF() { return ms.getBase(); }
+
+ public byte[] toType1BER(Properties config) throws PQFTranslationException {
+ System.out.println("in CQLBooleanNode.toType1BER(): PQF=" +
+ toPQF(config));
+ byte[] rpn1 = left.toType1BER(config);
+ byte[] rpn2 = right.toType1BER(config);
+ byte[] op = opType1();
+ byte[] rpnStructure = new byte[rpn1.length+rpn2.length+op.length+4];
+
+ // rpnRpnOp
+ int offset = putTag(CONTEXT, 1, CONSTRUCTED, rpnStructure, 0);
+
+ rpnStructure[offset++] = (byte)(0x80&0xff); // indefinite length
+ System.arraycopy(rpn1, 0, rpnStructure, offset, rpn1.length);
+ offset += rpn1.length;
+ System.arraycopy(rpn2, 0, rpnStructure, offset, rpn2.length);
+ offset += rpn2.length;
+ System.arraycopy(op, 0, rpnStructure, offset, op.length);
+ offset += op.length;
+ rpnStructure[offset++] = 0x00; // end rpnRpnOp
+ rpnStructure[offset++] = 0x00;
+ return rpnStructure;
+ }
- abstract String op();
+ abstract byte[] opType1();
}