1 // $Id: CQLPrefixNode.java,v 1.1 2002-12-04 16:54:01 mike Exp $
3 package org.z3950.zing.cql;
4 import java.lang.String;
5 import java.util.Properties;
6 import java.util.Vector;
10 * Represents a prefix node in a CQL parse-tree.
12 * @version $Id: CQLPrefixNode.java,v 1.1 2002-12-04 16:54:01 mike Exp $
14 public class CQLPrefixNode extends CQLNode {
16 * The prefix definition that governs the subtree.
18 public CQLPrefix prefix;
21 * The root of a parse-tree representing the part of the query
22 * that is governed by this prefix definition.
24 public CQLNode subtree;
27 * Creates a new CQLPrefixNode inducing a mapping from the
28 * specified qualifier-set name to the specified identifier across
29 * the specified subtree.
31 public CQLPrefixNode(String name, String identifier, CQLNode subtree) {
32 this.prefix = new CQLPrefix(name, identifier);
33 this.subtree = subtree;
36 public String toXCQL(int level, Vector prefixes) {
37 // String maybeName = "";
38 // if (prefix.name != null)
39 // maybeName = indent(level+1) + "<name>" + prefix.name + "</name>\n";
41 // return (indent(level) + "<prefix>\n" + maybeName +
43 // "<identifier>" + prefix.identifier + "</identifier>\n" +
44 // subtree.toXCQL(level+1, prefixes) +
45 // indent(level) + "</prefix>\n");
46 Vector tmp = new Vector(prefixes);
48 return subtree.toXCQL(level, tmp);
51 public String toCQL() {
52 // ### We don't always need parens around the operand
53 return ">" + prefix.name + "=\"" + prefix.identifier + "\" " +
54 "(" + subtree.toCQL() + ")";
57 public String toPQF(Properties config) throws PQFTranslationException {
58 // Prefixes and their identifiers don't actually play any role
59 // in PQF translation, since the meanings of the qualifiers,
60 // including their prefixes if any, are instead wired into
62 return subtree.toPQF(config);
65 public byte[] toType1(Properties config) throws PQFTranslationException {
66 // Prefixes and their identifiers don't actually play any role
67 // in PQF translation, since the meanings of the qualifiers,
68 // including their prefixes if any, are instead wired into
70 return subtree.toType1(config);