1 // $Id: CQLPrefixNode.java,v 1.2 2002-11-14 22:07:32 mike Exp $
3 package org.z3950.zing.cql;
4 import java.lang.String;
5 import java.util.Properties;
9 * Represents a prefix node in a CQL parse-tree.
11 * @version $Id: CQLPrefixNode.java,v 1.2 2002-11-14 22:07:32 mike Exp $
13 public class CQLPrefixNode extends CQLNode {
15 * The prefix definition that governs the subtree.
17 public CQLPrefix prefix;
20 * The root of a parse-tree representing the part of the query
21 * that is governed by this prefix definition.
23 public CQLNode subtree;
26 * Creates a new CQLPrefixNode inducing a mapping from the
27 * specified qualifier-set name to the specified identifier across
28 * the specified subtree.
30 public CQLPrefixNode(String name, String identifier, CQLNode subtree) {
31 this.prefix = new CQLPrefix(name, identifier);
32 this.subtree = subtree;
35 public String toXCQL(int level) {
36 String maybeName = "";
37 if (prefix.name != null)
38 maybeName = indent(level+1) + "<name>" + prefix.name + "</name>\n";
40 return (indent(level) + "<prefix>\n" + maybeName +
42 "<identifier>" + prefix.identifier + "</identifier>\n" +
43 subtree.toXCQL(level+1) +
44 indent(level) + "</prefix>\n");
47 public String toCQL() {
48 // ### We don't always need parens around the operand
49 return ">" + prefix.name + "=\"" + prefix.identifier + "\" " +
50 "(" + subtree.toCQL() + ")";
53 public String toPQF(Properties config) throws PQFTranslationException {
54 // Prefixes and their identifiers don't actually play any role
55 // in PQF translation, since the meanings of the qualifiers,
56 // including their prefixes if any, are instead wired into
58 return subtree.toPQF(config);