1 // $Id: CQLSortNode.java,v 1.1 2007-07-03 12:55:56 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.1 2007-07-03 12:55:56 mike Exp $
13 public class CQLSortNode extends CQLNode {
15 * The root of a subtree representing the query whose result is to
18 public 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 CQLSortNode(CQLNode subtree) {
28 this.subtree = subtree;
29 keys = new Vector<ModifierSet>();
32 public void addSortIndex(ModifierSet key) {
36 public String toXCQL(int level, Vector<CQLPrefix> prefixes,
37 Vector<ModifierSet> sortkeys) {
39 throw new Error("CQLSortNode.toXCQL() called with sortkeys");
40 return subtree.toXCQL(level, prefixes, keys);
43 public String toCQL() {
44 StringBuffer buf = new StringBuffer(subtree.toCQL());
47 buf.append(" sortby");
48 for (int i = 0; i < keys.size(); i++) {
49 ModifierSet key = keys.get(i);
50 buf.append(" " + key.toCQL());
54 return buf.toString();
57 public String toPQF(Properties config) throws PQFTranslationException {
58 return "@attr 1=oops \"###\"";
61 public byte[] toType1BER(Properties config)
62 throws PQFTranslationException {
63 // There is no way to represent sorting in a standard Z39.50
64 // Type-1 query, so the best we can do is return the
65 // underlying query and ignore the sort-specification.
66 return subtree.toType1BER(config);