Add classes for visitor traversal
[cql-java-moved-to-github.git] / src / main / java / org / z3950 / zing / cql / CQLAndNode.java
1
2 package org.z3950.zing.cql;
3
4
5 /**
6  * Represents an AND node in a CQL parse-tree.
7  *
8  */
9 public class CQLAndNode extends CQLBooleanNode {
10     /**
11      * Creates a new AND node with the specified left- and right-hand
12      * sides and modifiers.
13      */
14     public CQLAndNode(CQLNode left, CQLNode right, ModifierSet ms) {
15         super(left, right, ms);
16     }
17
18     @Override
19     public void traverse(CQLNodeVisitor visitor) {
20       visitor.onAndNode(this);
21       super.traverse(visitor);
22     }
23     
24
25     // ### Too much code duplication here with OR and NOT
26     @Override
27     byte[] opType1() {
28         byte[] op = new byte[5];
29         putTag(CONTEXT, 46, CONSTRUCTED, op, 0); // Operator
30         putLen(2, op, 2);
31         putTag(CONTEXT, 0, PRIMITIVE, op, 3); // and
32         putLen(0, op, 4);
33         return op;
34     }
35 }