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 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 Vector<ModifierSet> getSortIndexes() {
40 public String toXCQL(int level, Vector<CQLPrefix> prefixes,
41 Vector<ModifierSet> sortkeys) {
43 throw new Error("CQLSortNode.toXCQL() called with sortkeys");
44 return subtree.toXCQL(level, prefixes, keys);
47 public String toCQL() {
48 StringBuffer buf = new StringBuffer(subtree.toCQL());
51 buf.append(" sortby");
52 for (int i = 0; i < keys.size(); i++) {
53 ModifierSet key = keys.get(i);
54 buf.append(" " + key.toCQL());
58 return buf.toString();
61 public String toPQF(Properties config) throws PQFTranslationException {
62 return "@attr 1=oops \"###\"";
65 public byte[] toType1BER(Properties config)
66 throws PQFTranslationException {
67 // There is no way to represent sorting in a standard Z39.50
68 // Type-1 query, so the best we can do is return the
69 // underlying query and ignore the sort-specification.
70 return subtree.toType1BER(config);