including its mapping in "etc/pqf.properties".
- Make prefix-maps bind loosely, so that ``>dc=x a and b''
applies the dc=x binding to both the ``a'' and ``b''
sub-queries.
- Write javadoc comments for CQLRelation and ModifierSet.
- Other improvements to javadoc comments (e.g. describe the
`config' parameter to the toPQF() method.)
-$Id: Changes,v 1.12 2002-11-15 15:28:03 mike Exp $
+$Id: Changes,v 1.13 2002-11-17 23:29:02 mike Exp $
Revision history for "cql-java"
See the bottom of this file for a list of things still to do.
+0.4 (IN PROGRESS)
+ - Add support for the new "phonetic" relation modifier,
+ including its mapping in "etc/pqf.properties".
+ - Make prefix-maps bind loosely, so that ``>dc=x a and b''
+ applies the dc=x binding to both the ``a'' and ``b''
+ sub-queries.
+ - Change build process so that javadoc documentation is built
+ by "make" in the "docs" directory.
+ - Write javadoc comments for CQLRelation and ModifierSet.
+ - Other improvements to javadoc comments (e.g. describe the
+ `config' parameter to the toPQF() method.)
+
0.3 Fri Nov 15 12:04:04 2002
- Allow keywords to be used unquoted as search terms.
- Add support for serverChoiceRelation (scr).
- Fix the bug where "9x" is parsed as two tokens, a TT_NUMBER
followed by a TT_WORD. The problem here is that I don't
think it's actually possible to fix this without throwing
- out StreakTokenizer and rolling our own, which we absolutely
+ out StreamTokenizer and rolling our own, which we absolutely
_don't_ want to do.
- - Add support for the new "phonetic" relation modifier,
- including its mapping in "etc/pqf.properties".
- - Describe prefix-mapping in the CQL tutorial (not really
- anything to do with cql-java, but this note will remind me
- to do it.)
- - Write javadoc comments for CQLRelation and ModifierSet.
+ - Find out what the ZNG group finally settled on as the
+ correct XCQL representation of prefix-mapping, and tweak my
+ toXCQL() output to match that.
+ - Add srw.resultSet support to the toPFQ() method.
- Write "overview" file for the javadoc documentation.
- Some niceties for the cql-decompiling back-end:
* Don't emit redundant parentheses.
-# $Id: pqf.properties,v 1.3 2002-11-06 20:13:45 mike Exp $
+# $Id: pqf.properties,v 1.4 2002-11-17 23:29:02 mike Exp $
#
# Propeties file to drive org.z3950.zing.cql.CQLNode's toPQF()
# back-end. This specifies the interpretation of various CQL
# qualifiers to Attribute Architecture (util, XD and BIB-2)
# attributes.
-# The default access point:
-#
+# The default access point and result-set references
qualifier.srw.serverChoice = 1=1016
# "any"
+### This needs special support in the renderer
+qualifier.srw.resultSet = @set
+
qualifier.dc.title = 1=4
qualifier.dc.subject = 1=21
qualifier.dc.creator = 1=1003
relation.all = 2=3
relation.any = 2=3
+# BIB-1 doesn't have a server choice relation, so we just make the
+# choice here, and use equality (which is clearly correct).
+relation.scr = 2=3
+
# Relation modifiers.
#
relationModifier.relevant = 2=102
relationModifier.fuzzy = 2=100
### 100 is "phonetic", which is not quite the same thing
relationModifier.stem = 2=101
+relationModifier.phonetic = 2=100
# Position attributes may be specified for anchored terms (those
# beginning with "^", which is stripped) and unanchored (those not
-// $Id: CQLLexer.java,v 1.5 2002-11-14 22:04:16 mike Exp $
+// $Id: CQLLexer.java,v 1.6 2002-11-17 23:29:02 mike Exp $
package org.z3950.zing.cql;
import java.io.StreamTokenizer;
static int TT_FUZZY = 1017; // The "fuzzy" relation modifier
static int TT_STEM = 1018; // The "stem" relation modifier
static int TT_SCR = 1019; // The server choice relation
+ static int TT_PHONETIC = 1020; // The "phonetic" relation modifier
// Support for keywords. It would be nice to compile this linear
// list into a Hashtable, but it's hard to store ints as hash
new Keyword(TT_FUZZY, "fuzzy"),
new Keyword(TT_STEM, "stem"),
new Keyword(TT_SCR, "scr"),
+ new Keyword(TT_PHONETIC, "phonetic"),
};
// For halfDecentPushBack() and the code at the top of nextToken()
-// $Id: CQLNode.java,v 1.13 2002-11-08 16:32:01 mike Exp $
+// $Id: CQLNode.java,v 1.14 2002-11-17 23:29:02 mike Exp $
package org.z3950.zing.cql;
import java.util.Properties;
/**
* Represents a node in a CQL parse-tree.
*
- * @version $Id: CQLNode.java,v 1.13 2002-11-08 16:32:01 mike Exp $
+ * @version $Id: CQLNode.java,v 1.14 2002-11-17 23:29:02 mike Exp $
*/
public abstract class CQLNode {
CQLNode() {} // prevent javadoc from documenting this
* >Chapter 7 (Supporting Tools)</A> of the
* <A href="http://indexdata.dk/yaz/">YAZ</A> manual.
* <P>
+ * @param config
+ * A <TT>Properties</TT> 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,
+ * <TT>etc/pqf.properties</TT>, 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
-// $Id: CQLParser.java,v 1.20 2002-11-14 22:04:16 mike Exp $
+// $Id: CQLParser.java,v 1.21 2002-11-17 23:29:02 mike Exp $
package org.z3950.zing.cql;
import java.io.IOException;
/**
* Compiles CQL strings into parse trees of CQLNode subtypes.
*
- * @version $Id: CQLParser.java,v 1.20 2002-11-14 22:04:16 mike Exp $
+ * @version $Id: CQLParser.java,v 1.21 2002-11-17 23:29:02 mike Exp $
* @see <A href="http://zing.z3950.org/cql/index.html"
* >http://zing.z3950.org/cql/index.html</A>
*/
match('/');
if (lexer.ttype != lexer.TT_RELEVANT &&
lexer.ttype != lexer.TT_FUZZY &&
- lexer.ttype != lexer.TT_STEM)
+ lexer.ttype != lexer.TT_STEM &&
+ lexer.ttype != lexer.TT_PHONETIC)
throw new CQLParseException("expected relation modifier, "
+ "got " + lexer.render());
relation.addModifier(lexer.sval.toLowerCase());
name = identifier;
identifier = matchSymbol("prefix-identifer");
}
- CQLNode term = parseTerm(qualifier, relation);
+ CQLNode term = parseQuery(qualifier, relation);
return new CQLPrefixNode(name, identifier, term);
}
lexer.ttype == lexer.TT_SCR);
}
+ // Checks for a relation that may be used inside a prox operator
private boolean isProxRelation() {
debug("isProxRelation: checking ttype=" + lexer.ttype +
" (" + lexer.render() + ")");
// 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.
+ // ### Instead, we should ask the lexer whether what we
+ // have is a keyword, and let the knowledge reside there.
lexer.ttype == lexer.TT_AND ||
lexer.ttype == lexer.TT_OR ||
lexer.ttype == lexer.TT_NOT ||
lexer.ttype == lexer.TT_RELEVANT ||
lexer.ttype == lexer.TT_FUZZY ||
lexer.ttype == lexer.TT_STEM ||
- lexer.ttype == lexer.TT_SCR) {
+ lexer.ttype == lexer.TT_SCR ||
+ lexer.ttype == lexer.TT_PHONETIC) {
String symbol = (lexer.ttype == lexer.TT_NUMBER) ?
lexer.render() : lexer.sval;
match(lexer.ttype);
-// $Id: CQLRelation.java,v 1.5 2002-11-06 20:13:45 mike Exp $
+// $Id: CQLRelation.java,v 1.6 2002-11-17 23:29:02 mike Exp $
package org.z3950.zing.cql;
import java.util.Vector;
/**
* Represents a relation between a CQL qualifier and term.
*
- * @version $Id: CQLRelation.java,v 1.5 2002-11-06 20:13:45 mike Exp $
+ * @version $Id: CQLRelation.java,v 1.6 2002-11-17 23:29:02 mike Exp $
*/
public class CQLRelation extends CQLNode {
ModifierSet ms;
+ /**
+ * Creates a new CQLRelation with the specified base relation.
+ * Typical base relations include the usual six ordering relations
+ * (<TT><=</TT>, <TT>></TT>, <I>etc.</I>), the text
+ * relations <TT>any</TT>, <TT>all</TT> and <TT>exact</TT> and the
+ * server-choice relation <TT>scr</TT>.
+ */
public CQLRelation(String base) {
ms = new ModifierSet(base);
}
+ /**
+ * Returns the base relation with which the CQLRelation was
+ * originally created.
+ */
public String getBase() {
return ms.getBase();
}
+ /**
+ * Adds a new relation modifier to the specified CQLRelation.
+ * Typical relation modifiers include <TT>relevant</TT>,
+ * <TT>fuzzy</TT>, <TT>stem</TT> and <TT>phonetic</TT>. On the
+ * whole, these modifiers have a meaningful interpretation only
+ * for the text relations.
+ */
public void addModifier(String modifier) {
ms.addModifier(null, modifier);
}
+ /**
+ * Returns an array of the modifiers associated with a CQLRelation.
+ * @return
+ * An array of zero or more <TT>String</TT>s, each representing a
+ * modifier associated with the specified CQLRelation.
+ */
public String[] getModifiers() {
Vector[] v = ms.getModifiers();
int n = v.length;
-# $Id: Makefile,v 1.11 2002-11-14 22:04:16 mike Exp $
+# $Id: Makefile,v 1.12 2002-11-17 23:29:02 mike Exp $
#
-# Your Java compiler, and javadoc, will require that this source
-# directory is on the classpath. The best way to do that is just to
-# add the cql-java distribution's "src" subdirectory to your CLASSPATH
-# environment variable, like this:
+# Your Java compiler will require that this source directory is on the
+# classpath. The best way to do that is just to add the cql-java
+# distribution's "src" subdirectory to your CLASSPATH environment
+# variable, like this:
# CLASSPATH=$CLASSPATH:/where/ever/you/unpacked/it/cql-java-VERSION/src
-DOCDIR = ../../../../../docs
-
OBJ = Utils.class \
CQLNode.class CQLTermNode.class CQLBooleanNode.class \
CQLAndNode.class CQLOrNode.class CQLNotNode.class \
%.class: %.java
javac $<
-docs: $(DOCDIR)/overview-tree.html
-
-$(DOCDIR)/overview-tree.html: *.java
- nice javadoc -d $(DOCDIR) -author -version \
- -windowtitle cql-java org.z3950.zing.cql
-
clean:
rm -f $(OBJ) 'CQLLexer$$Keyword.class'
-cleandocs:
- rm -rf $(DOCDIR)/allclasses-frame.html \
- $(DOCDIR)/deprecated-list.html \
- $(DOCDIR)/help-doc.html \
- $(DOCDIR)/index-all.html \
- $(DOCDIR)/index.html \
- $(DOCDIR)/org \
- $(DOCDIR)/overview-tree.html \
- $(DOCDIR)/package-list \
- $(DOCDIR)/packages.html \
- $(DOCDIR)/serialized-form.html \
- $(DOCDIR)/stylesheet.css
-// $Id: ModifierSet.java,v 1.4 2002-11-06 20:13:45 mike Exp $
+// $Id: ModifierSet.java,v 1.5 2002-11-17 23:29:02 mike Exp $
package org.z3950.zing.cql;
import java.util.Vector;
* <P>
* This class is used as a workhorse delegate by both CQLRelation and
* CQLProxNode - two functionally very separate classes that happen to
- * require the same data structures and functionality.
+ * require similar data structures and functionality.
+ * <P>
+ * A ModifierSet consists of a ``base'' string together with a set of
+ * zero or more <I>type</I>=<I>value</I> pairs, where both type and
+ * value are strings. Types may be null, values may not.
*
- * @version $Id: ModifierSet.java,v 1.4 2002-11-06 20:13:45 mike Exp $
+ * @version $Id: ModifierSet.java,v 1.5 2002-11-17 23:29:02 mike Exp $
*/
public class ModifierSet {
String base;
Vector modifiers;
+ /**
+ * Creates a new ModifierSet with the specified base.
+ */
public ModifierSet(String base) {
this.base = base;
modifiers = new Vector();
}
+ /**
+ * Returns the base string with which the ModifierSet was created.
+ */
public String getBase() {
return base;
}
+ /**
+ * Adds a modifier of the specified <TT>type</TT> and
+ * <TT>value</TT> to a ModifierSet.
+ */
public void addModifier(String type, String value) {
Vector modifier = new Vector();
modifier.add(type);
modifiers.add(modifier);
}
+ /**
+ * Returns the value of the modifier in the specified ModifierSet
+ * that corresponds to the specified type.
+ */
public String modifier(String type) {
int n = modifiers.size();
for (int i = 0; i < n; i++) {
return null;
}
+ /**
+ * Returns an array of the modifiers in a ModifierSet.
+ * @return
+ * An array of modifiers, each represented by a two-element
+ * <TT>Vector</TT>, in which element 0 is the modifier type and
+ * element 1 is the associated value.
+ */
public Vector[] getModifiers() {
int n = modifiers.size();
Vector[] res = new Vector[n];