From: mike Date: Wed, 27 Jun 2007 22:39:55 +0000 (+0000) Subject: 'qualifier' replaced by 'index' throughout X-Git-Tag: v1.5~112 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=55136632bf2d7d9a54fe08bbb89bed6c03eb70b1;p=cql-java-moved-to-github.git 'qualifier' replaced by 'index' throughout --- diff --git a/src/org/z3950/zing/cql/CQLGenerator.java b/src/org/z3950/zing/cql/CQLGenerator.java index 2ff3b76..7cde23e 100644 --- a/src/org/z3950/zing/cql/CQLGenerator.java +++ b/src/org/z3950/zing/cql/CQLGenerator.java @@ -1,4 +1,4 @@ -// $Id: CQLGenerator.java,v 1.6 2007-06-06 15:13:41 mike Exp $ +// $Id: CQLGenerator.java,v 1.7 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -22,7 +22,7 @@ import java.io.FileNotFoundException; * this distribution - there is a generate_x() method * for each grammar element X. * - * @version $Id: CQLGenerator.java,v 1.6 2007-06-06 15:13:41 mike Exp $ + * @version $Id: CQLGenerator.java,v 1.7 2007-06-27 22:39:55 mike Exp $ * @see http://zing.z3950.org/cql/index.html */ @@ -64,7 +64,7 @@ public class CQLGenerator { * [mandatory] A floating-point number between 0.0 and 1.0, * indicating the probability for each search-clause * node that it will be expanded into a full sub-query rather - * than a [ qualifier relation ] term triplet. + * than an [ index relation ] term triplet. *

* *

proxOp
@@ -155,33 +155,33 @@ public class CQLGenerator { return generate_cql_query(); } - // ### Should sometimes generate qualifier/relation-free terms - String qualifier = generate_qualifier(); + // ### Should sometimes generate index/relation-free terms + String index = generate_index(); CQLRelation relation = generate_relation(); String term = generate_term(); - return new CQLTermNode(qualifier, relation, term); + return new CQLTermNode(index, relation, term); } // ### Should probably be more configurable - private String generate_qualifier() { - String qualifier = ""; // shut up compiler warning + private String generate_index() { + String index = ""; // shut up compiler warning if (rnd.nextInt(2) == 0) { switch (rnd.nextInt(3)) { - case 0: qualifier = "dc.author"; break; - case 1: qualifier = "dc.title"; break; - case 2: qualifier = "dc.subject"; break; + case 0: index = "dc.author"; break; + case 1: index = "dc.title"; break; + case 2: index = "dc.subject"; break; } } else { switch (rnd.nextInt(4)) { - case 0: qualifier = "bath.author"; break; - case 1: qualifier = "bath.title"; break; - case 2: qualifier = "bath.subject"; break; - case 3: qualifier = "foo>bar"; break; + case 0: index = "bath.author"; break; + case 1: index = "bath.title"; break; + case 2: index = "bath.subject"; break; + case 3: index = "foo>bar"; break; } } - return qualifier; + return index; } private CQLRelation generate_relation() throws MissingParameterException { diff --git a/src/org/z3950/zing/cql/CQLNode.java b/src/org/z3950/zing/cql/CQLNode.java index 4a11592..2852126 100644 --- a/src/org/z3950/zing/cql/CQLNode.java +++ b/src/org/z3950/zing/cql/CQLNode.java @@ -1,4 +1,4 @@ -// $Id: CQLNode.java,v 1.24 2007-06-06 13:19:28 mike Exp $ +// $Id: CQLNode.java,v 1.25 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -8,7 +8,7 @@ import java.util.Vector; /** * Represents a node in a CQL parse-tree. * - * @version $Id: CQLNode.java,v 1.24 2007-06-06 13:19:28 mike Exp $ + * @version $Id: CQLNode.java,v 1.25 2007-06-27 22:39:55 mike Exp $ */ public abstract class CQLNode { CQLNode() {} // prevent javadoc from documenting this @@ -81,7 +81,7 @@ public abstract class CQLNode { *

* @param config * A Properties object containing configuration - * information that specifies the mapping from CQL qualifiers, + * information that specifies the mapping from CQL indexes, * relations, etc. to Type-1 attributes. The mapping * specification is described in the CQL-Java distribution's * sample PQF-mapping configuration file, @@ -113,7 +113,7 @@ public abstract class CQLNode { * * @param config * A Properties object containing configuration - * information that specifies the mapping from CQL qualifiers, + * information that specifies the mapping from CQL indexes, * relations, etc. to Type-1 attributes. The mapping * specification is described in the CQL-Java distribution's * sample PQF-mapping configuration file, diff --git a/src/org/z3950/zing/cql/CQLParser.java b/src/org/z3950/zing/cql/CQLParser.java index 84b0488..304d7b5 100644 --- a/src/org/z3950/zing/cql/CQLParser.java +++ b/src/org/z3950/zing/cql/CQLParser.java @@ -1,4 +1,4 @@ -// $Id: CQLParser.java,v 1.26 2007-06-27 22:16:23 mike Exp $ +// $Id: CQLParser.java,v 1.27 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.io.IOException; @@ -12,7 +12,7 @@ import java.io.FileNotFoundException; /** * Compiles CQL strings into parse trees of CQLNode subtypes. * - * @version $Id: CQLParser.java,v 1.26 2007-06-27 22:16:23 mike Exp $ + * @version $Id: CQLParser.java,v 1.27 2007-06-27 22:39:55 mike Exp $ * @see http://zing.z3950.org/cql/index.html */ @@ -55,30 +55,30 @@ public class CQLParser { return root; } - private CQLNode parseQuery(String qualifier, CQLRelation relation) + private CQLNode parseQuery(String index, CQLRelation relation) throws CQLParseException, IOException { debug("in parseQuery()"); - CQLNode term = parseTerm(qualifier, relation); + CQLNode term = parseTerm(index, relation); while (lexer.ttype != lexer.TT_EOF && lexer.ttype != ')') { if (lexer.ttype == lexer.TT_AND) { match(lexer.TT_AND); - CQLNode term2 = parseTerm(qualifier, relation); + CQLNode term2 = parseTerm(index, relation); term = new CQLAndNode(term, term2); } else if (lexer.ttype == lexer.TT_OR) { match(lexer.TT_OR); - CQLNode term2 = parseTerm(qualifier, relation); + CQLNode term2 = parseTerm(index, relation); term = new CQLOrNode(term, term2); } else if (lexer.ttype == lexer.TT_NOT) { match(lexer.TT_NOT); - CQLNode term2 = parseTerm(qualifier, relation); + CQLNode term2 = parseTerm(index, relation); term = new CQLNotNode(term, term2); } else if (lexer.ttype == lexer.TT_PROX) { match(lexer.TT_PROX); CQLProxNode proxnode = new CQLProxNode(term); gatherProxParameters(proxnode); - CQLNode term2 = parseTerm(qualifier, relation); + CQLNode term2 = parseTerm(index, relation); proxnode.addSecondSubterm(term2); term = (CQLNode) proxnode; } else { @@ -91,7 +91,7 @@ public class CQLParser { return term; } - private CQLNode parseTerm(String qualifier, CQLRelation relation) + private CQLNode parseTerm(String index, CQLRelation relation) throws CQLParseException, IOException { debug("in parseTerm()"); @@ -100,20 +100,20 @@ public class CQLParser { if (lexer.ttype == '(') { debug("parenthesised term"); match('('); - CQLNode expr = parseQuery(qualifier, relation); + CQLNode expr = parseQuery(index, relation); match(')'); return expr; } else if (lexer.ttype == '>') { match('>'); - return parsePrefix(qualifier, relation); + return parsePrefix(index, relation); } debug("non-parenthesised term"); - word = matchSymbol("qualifier or term"); + word = matchSymbol("index or term"); if (!isBaseRelation()) break; - qualifier = word; + index = word; relation = new CQLRelation(lexer.ttype == lexer.TT_WORD ? lexer.sval : lexer.render(lexer.ttype, false)); @@ -138,16 +138,16 @@ public class CQLParser { match(lexer.ttype); } - debug("qualifier='" + qualifier + ", " + + debug("index='" + index + ", " + "relation='" + relation.toCQL() + "'"); } - CQLTermNode node = new CQLTermNode(qualifier, relation, word); + CQLTermNode node = new CQLTermNode(index, relation, word); debug("made term node " + node.toCQL()); return node; } - private CQLNode parsePrefix(String qualifier, CQLRelation relation) + private CQLNode parsePrefix(String index, CQLRelation relation) throws CQLParseException, IOException { debug("prefix mapping"); @@ -158,7 +158,7 @@ public class CQLParser { name = identifier; identifier = matchSymbol("prefix-identifer"); } - CQLNode term = parseQuery(qualifier, relation); + CQLNode term = parseQuery(index, relation); return new CQLPrefixNode(name, identifier, term); } @@ -277,7 +277,7 @@ public class CQLParser { lexer.ttype == '"' || // The following is a complete list of keywords. Because // they're listed here, they can be used unquoted as - // qualifiers, terms, prefix names and prefix identifiers. + // indexes, terms, prefix names and prefix identifiers. // ### Instead, we should ask the lexer whether what we // have is a keyword, and let the knowledge reside there. lexer.ttype == lexer.TT_AND || @@ -440,7 +440,7 @@ public class CQLParser { System.err.println("Can't render query: " + ex.getMessage()); System.exit(5); } catch (UnknownQualifierException ex) { - System.err.println("Unknown qualifier: " + ex.getMessage()); + System.err.println("Unknown index: " + ex.getMessage()); System.exit(6); } catch (UnknownRelationException ex) { System.err.println("Unknown relation: " + ex.getMessage()); diff --git a/src/org/z3950/zing/cql/CQLPrefix.java b/src/org/z3950/zing/cql/CQLPrefix.java index fd751a7..af7c906 100644 --- a/src/org/z3950/zing/cql/CQLPrefix.java +++ b/src/org/z3950/zing/cql/CQLPrefix.java @@ -1,4 +1,4 @@ -// $Id: CQLPrefix.java,v 1.4 2002-11-20 09:49:29 mike Exp $ +// $Id: CQLPrefix.java,v 1.5 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.lang.String; @@ -6,19 +6,19 @@ import java.lang.String; /** * Represents a CQL prefix mapping from short name to long identifier. * - * @version $Id: CQLPrefix.java,v 1.4 2002-11-20 09:49:29 mike Exp $ + * @version $Id: CQLPrefix.java,v 1.5 2007-06-27 22:39:55 mike Exp $ */ public class CQLPrefix { /** * The short name of the prefix mapping. That is, the prefix - * itself, such as dc, as it might be used in a qualifier + * itself, such as dc, as it might be used in an index * like dc.title. */ public String name; /** * The full identifier name of the prefix mapping. That is, - * typically, a URI permanently allocated to a specific qualifier + * typically, a URI permanently allocated to a specific index * set, such as http://zthes.z3950.org/cql/1.0. */ public String identifier; diff --git a/src/org/z3950/zing/cql/CQLPrefixNode.java b/src/org/z3950/zing/cql/CQLPrefixNode.java index a152fcc..a08fa64 100644 --- a/src/org/z3950/zing/cql/CQLPrefixNode.java +++ b/src/org/z3950/zing/cql/CQLPrefixNode.java @@ -1,4 +1,4 @@ -// $Id: CQLPrefixNode.java,v 1.7 2007-06-26 16:36:50 mike Exp $ +// $Id: CQLPrefixNode.java,v 1.8 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.lang.String; @@ -9,7 +9,7 @@ import java.util.Vector; /** * Represents a prefix node in a CQL parse-tree. * - * @version $Id: CQLPrefixNode.java,v 1.7 2007-06-26 16:36:50 mike Exp $ + * @version $Id: CQLPrefixNode.java,v 1.8 2007-06-27 22:39:55 mike Exp $ */ public class CQLPrefixNode extends CQLNode { /** @@ -25,7 +25,7 @@ public class CQLPrefixNode extends CQLNode { /** * Creates a new CQLPrefixNode inducing a mapping from the - * specified qualifier-set name to the specified identifier across + * specified index-set name to the specified identifier across * the specified subtree. */ public CQLPrefixNode(String name, String identifier, CQLNode subtree) { @@ -61,7 +61,7 @@ public class CQLPrefixNode extends CQLNode { public String toPQF(Properties config) throws PQFTranslationException { // Prefixes and their identifiers don't actually play any role - // in PQF translation, since the meanings of the qualifiers, + // in PQF translation, since the meanings of the indexes, // including their prefixes if any, are instead wired into // `config'. return subtree.toPQF(config); diff --git a/src/org/z3950/zing/cql/CQLRelation.java b/src/org/z3950/zing/cql/CQLRelation.java index 49e9f63..6e4ec9b 100644 --- a/src/org/z3950/zing/cql/CQLRelation.java +++ b/src/org/z3950/zing/cql/CQLRelation.java @@ -1,4 +1,4 @@ -// $Id: CQLRelation.java,v 1.14 2007-06-27 22:14:46 mike Exp $ +// $Id: CQLRelation.java,v 1.15 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.util.Vector; @@ -6,9 +6,9 @@ import java.util.Properties; import java.lang.StringBuffer; /** - * Represents a relation between a CQL qualifier and term. + * Represents a relation between a CQL index and term. * - * @version $Id: CQLRelation.java,v 1.14 2007-06-27 22:14:46 mike Exp $ + * @version $Id: CQLRelation.java,v 1.15 2007-06-27 22:39:55 mike Exp $ */ public class CQLRelation extends CQLNode { ModifierSet ms; diff --git a/src/org/z3950/zing/cql/CQLTermNode.java b/src/org/z3950/zing/cql/CQLTermNode.java index 070955c..fc310ed 100644 --- a/src/org/z3950/zing/cql/CQLTermNode.java +++ b/src/org/z3950/zing/cql/CQLTermNode.java @@ -1,4 +1,4 @@ -// $Id: CQLTermNode.java,v 1.24 2007-06-27 17:05:05 mike Exp $ +// $Id: CQLTermNode.java,v 1.25 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -8,40 +8,41 @@ import java.util.Vector; /** * Represents a terminal node in a CQL parse-tree. * A term node consists of the term String itself, together with, - * optionally, a qualifier string and a relation. Neither or both of - * these must be provided - you can't have a qualifier without a + * optionally, an index string and a relation. Neither or both of + * these must be provided - you can't have an index without a * relation or vice versa. * - * @version $Id: CQLTermNode.java,v 1.24 2007-06-27 17:05:05 mike Exp $ + * @version $Id: CQLTermNode.java,v 1.25 2007-06-27 22:39:55 mike Exp $ */ public class CQLTermNode extends CQLNode { - private String qualifier; + private String index; private CQLRelation relation; private String term; /** - * Creates a new term node with the specified qualifier, + * Creates a new term node with the specified index, * relation and term. The first two may be * null, but the term may not. */ - public CQLTermNode(String qualifier, CQLRelation relation, String term) { - this.qualifier = qualifier; + public CQLTermNode(String index, CQLRelation relation, String term) { + this.index = index; this.relation = relation; this.term = term; } - public String getQualifier() { return qualifier; } + public String getIndex() { return index; } + public String getQualifier() { return getIndex(); } // for legacy applications public CQLRelation getRelation() { return relation; } public String getTerm() { return term; } - private static boolean isResultSetQualifier(String qual) { + private static boolean isResultSetIndex(String qual) { return (qual.equals("srw.resultSet") || qual.equals("srw.resultSetId") || qual.equals("srw.resultSetName")); } public String getResultSetName() { - if (isResultSetQualifier(qualifier)) + if (isResultSetIndex(index)) return term; else return null; @@ -50,21 +51,21 @@ public class CQLTermNode extends CQLNode { public String toXCQL(int level, Vector prefixes) { return (indent(level) + "\n" + renderPrefixes(level+1, prefixes) + - indent(level+1) + "" + xq(qualifier) + "\n" + + indent(level+1) + "" + xq(index) + "\n" + relation.toXCQL(level+1, new Vector()) + indent(level+1) + "" + xq(term) + "\n" + indent(level) + "\n"); } public String toCQL() { - String quotedQualifier = maybeQuote(qualifier); + String quotedIndex = maybeQuote(index); String quotedTerm = maybeQuote(term); String res = quotedTerm; - if (qualifier != null && - !qualifier.equalsIgnoreCase("srw.serverChoice")) { + if (index != null && + !index.equalsIgnoreCase("srw.serverChoice")) { // ### We don't always need spaces around `relation'. - res = quotedQualifier + " " + relation.toCQL() + " " + quotedTerm; + res = quotedIndex + " " + relation.toCQL() + " " + quotedTerm; } return res; @@ -88,9 +89,9 @@ public class CQLTermNode extends CQLNode { if (attr != null) attrs.add(attr); - attr = config.getProperty("qualifier." + qualifier); + attr = config.getProperty("index." + index); if (attr == null) - throw new UnknownQualifierException(qualifier); + throw new UnknownQualifierException(index); attrs.add(attr); String rel = relation.getBase(); @@ -149,7 +150,7 @@ public class CQLTermNode extends CQLNode { } public String toPQF(Properties config) throws PQFTranslationException { - if (isResultSetQualifier(qualifier)) { + if (isResultSetIndex(index)) { // Special case: ignore relation, modifiers, wildcards, etc. // There's parallel code in toType1BER() return "@set " + maybeQuote(term); @@ -195,7 +196,7 @@ public class CQLTermNode extends CQLNode { } public byte[] toType1BER(Properties config) throws PQFTranslationException { - if (isResultSetQualifier(qualifier)) { + if (isResultSetIndex(index)) { // Special case: ignore relation, modifiers, wildcards, etc. // There's parallel code in toPQF() byte[] operand = new byte[term.length()+100]; diff --git a/src/org/z3950/zing/cql/UnknownQualifierException.java b/src/org/z3950/zing/cql/UnknownQualifierException.java index 8bad79e..009ef9c 100644 --- a/src/org/z3950/zing/cql/UnknownQualifierException.java +++ b/src/org/z3950/zing/cql/UnknownQualifierException.java @@ -1,24 +1,24 @@ -// $Id: UnknownQualifierException.java,v 1.2 2002-11-06 20:13:45 mike Exp $ +// $Id: UnknownQualifierException.java,v 1.3 2007-06-27 22:39:55 mike Exp $ package org.z3950.zing.cql; import java.lang.Exception; /** - * Exception indicating that a qualifier was not recognised. - * At compilation time, we accept any syntactically valid qualifier; + * Exception indicating that an index was not recognised. + * At compilation time, we accept any syntactically valid index; * but when rendering a tree out as PQF, we need to translate the - * qualifiers into sets of Type-1 query attributes. If we can't do + * indexes into sets of Type-1 query attributes. If we can't do * that, because the PQF configuration doesn't know about a relation, * we throw one of these babies. * - * @version $Id: UnknownQualifierException.java,v 1.2 2002-11-06 20:13:45 mike Exp $ + * @version $Id: UnknownQualifierException.java,v 1.3 2007-06-27 22:39:55 mike Exp $ */ public class UnknownQualifierException extends PQFTranslationException { /** * Creates a new UnknownQualifierException. * @param s - * The qualifier for which there was no PQF configuration. + * The index for which there was no PQF configuration. */ public UnknownQualifierException(String s) { super(s);