1 // $Id: CQLSortNode.java,v 1.2 2008-04-11 12:05:15 mike Exp $
3 package org.z3950.zing.cql;
4 import java.util.Properties;
5 import java.util.Vector;
9 * Represents a sort node in a CQL parse-tree.
11 * @version $Id: CQLSortNode.java,v 1.2 2008-04-11 12:05:15 mike Exp $
13 public class CQLSortNode extends CQLNode {
15 * The root of a subtree representing the query whose result is to
18 private CQLNode subtree;
21 * The set of sort keys by which results are to be sorted,
22 * each expressed as an index together with zero or more
25 Vector<ModifierSet> keys;
27 public CQLNode getSubtree() {
31 public CQLSortNode(CQLNode subtree) {
32 this.subtree = subtree;
33 keys = new Vector<ModifierSet>();
36 public void addSortIndex(ModifierSet key) {
40 public Vector<ModifierSet> getSortIndexes() {
44 public String toXCQL(int level, Vector<CQLPrefix> prefixes,
45 Vector<ModifierSet> sortkeys) {
47 throw new Error("CQLSortNode.toXCQL() called with sortkeys");
48 return subtree.toXCQL(level, prefixes, keys);
51 public String toCQL() {
52 StringBuffer buf = new StringBuffer(subtree.toCQL());
55 buf.append(" sortby");
56 for (int i = 0; i < keys.size(); i++) {
57 ModifierSet key = keys.get(i);
58 buf.append(" " + key.toCQL());
62 return buf.toString();
65 public String toPQF(Properties config) throws PQFTranslationException {
66 return "@attr 1=oops \"###\"";
69 public byte[] toType1BER(Properties config)
70 throws PQFTranslationException {
71 // There is no way to represent sorting in a standard Z39.50
72 // Type-1 query, so the best we can do is return the
73 // underlying query and ignore the sort-specification.
74 return subtree.toType1BER(config);