X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Forg%2Fz3950%2Fzing%2Fcql%2FCQLNode.java;h=5965da621c6eea1afa47700f5ebfad68da2e3d0d;hb=561a15208b3be53c0ad3a1eb5524badfc377c478;hp=eab6db40f12af4f582b47d0f3d870bedc7a9077d;hpb=fc82b225d39cc66cb85c2557db0c0d4a4c5a6e27;p=cql-java-moved-to-github.git diff --git a/src/org/z3950/zing/cql/CQLNode.java b/src/org/z3950/zing/cql/CQLNode.java index eab6db4..5965da6 100644 --- a/src/org/z3950/zing/cql/CQLNode.java +++ b/src/org/z3950/zing/cql/CQLNode.java @@ -1,13 +1,14 @@ -// $Id: CQLNode.java,v 1.12 2002-11-06 20:13:45 mike Exp $ +// $Id: CQLNode.java,v 1.15 2002-11-20 01:15:15 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; +import java.util.Vector; /** * Represents a node in a CQL parse-tree. * - * @version $Id: CQLNode.java,v 1.12 2002-11-06 20:13:45 mike Exp $ + * @version $Id: CQLNode.java,v 1.15 2002-11-20 01:15:15 mike Exp $ */ public abstract class CQLNode { CQLNode() {} // prevent javadoc from documenting this @@ -24,7 +25,27 @@ public abstract class CQLNode { * A String containing an XCQL document equivalent to the * parse-tree whose root is this node. */ - abstract public String toXCQL(int level); + public String toXCQL(int level) { + return toXCQL(level, new Vector()); + } + + abstract public String toXCQL(int level, Vector prefixes); + + protected static String renderPrefixes(int level, Vector prefixes) { + if (prefixes.size() == 0) + return ""; + String res = indent(level) + "\n"; + for (int i = 0; i < prefixes.size(); i++) { + CQLPrefix p = (CQLPrefix) prefixes.get(i); + res += indent(level+1) + "\n"; + if (p.name != null) + res += indent(level+2) + "" + p.name + "\n"; + res += indent(level+2) + + "" + p.identifier + "\n"; + res += indent(level+1) + "\n"; + } + return res + indent(level) + "\n"; + } /** * Decompiles a parse-tree into a CQL query. @@ -38,26 +59,21 @@ public abstract class CQLNode { /** * Renders a parse-tree into a Yaz-style PQF string. + * PQF, or Prefix Query Format, is a cryptic but powerful notation + * that can be trivially mapped, one-to-one, int Z39.50 Type-1 and + * Type-101 queries. A specification for the format can be found + * in + * Chapter 7 (Supporting Tools) of the + * YAZ manual. *

- *

-	query ::= top-set query-struct.
-	top-set ::= [ '@attrset' string ]
-	query-struct ::= attr-spec | simple | complex | '@term' term-type
-	attr-spec ::= '@attr' [ string ] string query-struct
-	complex ::= operator query-struct query-struct.
-	operator ::= '@and' | '@or' | '@not' | '@prox' proximity.
-	simple ::= result-set | term.
-	result-set ::= '@set' string.
-	term ::= string.
-	proximity ::= exclusion distance ordered relation which-code unit-code.
-	exclusion ::= '1' | '0' | 'void'.
-	distance ::= integer.
-	ordered ::= '1' | '0'.
-	relation ::= integer.
-	which-code ::= 'known' | 'private' | integer.
-	unit-code ::= integer.
-	term-type ::= 'general' | 'numeric' | 'string' | 'oid' | 'datetime' | 'null'.
-     * 
+ * @param config + * A Properties object containing configuration + * information that specifies the mapping from CQL qualifiers, + * relations, etc. to Type-1 attributes. The mapping + * specification is described in the cql-java distribution's + * sample PQF-mapping configuration file, + * etc/pqf.properties, which see. * @return * A String containing a PQF query equivalent to the parse-tree * whose root is this node. This may be fed into the tool of