From c0cf61216e9a8d036a7aee17f1b24136a6630e65 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 4 Sep 2003 21:56:46 +0000 Subject: [PATCH] Release 0.7 -- understands profiles relations and modifiers. --- Changes | 9 ++++++++- VERSION | 2 +- src/org/z3950/zing/cql/CQLParser.java | 29 +++++++++++++++++++++++------ src/org/z3950/zing/cql/CQLRelation.java | 9 +++++---- 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Changes b/Changes index 6385752..822b943 100644 --- a/Changes +++ b/Changes @@ -1,8 +1,15 @@ -$Id: Changes,v 1.32 2003-07-29 22:53:02 mike Exp $ +$Id: Changes,v 1.33 2003-09-04 21:56:46 mike Exp $ Revision history for the CQL-Java package. See the bottom of this file for a list of things still to do. +0.7 Thu Sep 4 22:51:11 2003 + - Support for profiled relations and relation modifiers: + recognise any non-key word as a relation or modifier, + rejecting those that are not of the form . + since these must be explicitly tied to a "context" (what + used to be called a qualifier-set or index-set). + 0.6 Tue Jul 29 23:33:56 2003 - Include Ralph's fix for CQLTermNode::toType1BER() to prevent it surrounding multi-word terms in quotes when encoded into diff --git a/VERSION b/VERSION index 5a2a580..eb49d7c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6 +0.7 diff --git a/src/org/z3950/zing/cql/CQLParser.java b/src/org/z3950/zing/cql/CQLParser.java index 85ee63b..13e505e 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.22 2002-11-20 01:15:15 mike Exp $ +// $Id: CQLParser.java,v 1.23 2003-09-04 21:56:46 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.22 2002-11-20 01:15:15 mike Exp $ + * @version $Id: CQLParser.java,v 1.23 2003-09-04 21:56:46 mike Exp $ * @see http://zing.z3950.org/cql/index.html */ @@ -114,7 +114,9 @@ public class CQLParser { break; qualifier = word; - relation = new CQLRelation(lexer.render(lexer.ttype, false)); + relation = new CQLRelation(lexer.ttype == lexer.TT_WORD ? + lexer.sval : + lexer.render(lexer.ttype, false)); match(lexer.ttype); while (lexer.ttype == '/') { @@ -122,9 +124,16 @@ public class CQLParser { if (lexer.ttype != lexer.TT_RELEVANT && lexer.ttype != lexer.TT_FUZZY && lexer.ttype != lexer.TT_STEM && - lexer.ttype != lexer.TT_PHONETIC) + lexer.ttype != lexer.TT_PHONETIC && + lexer.ttype != lexer.TT_WORD) throw new CQLParseException("expected relation modifier, " + "got " + lexer.render()); + if (lexer.ttype == lexer.TT_WORD && + lexer.sval.indexOf('.') == -1) + throw new CQLParseException("unknown first-class " + + "relation modifier: " + + lexer.sval); + relation.addModifier(lexer.sval.toLowerCase()); match(lexer.ttype); } @@ -216,14 +225,22 @@ public class CQLParser { match(lexer.ttype); } - private boolean isBaseRelation() { + private boolean isBaseRelation() + throws CQLParseException { debug("isBaseRelation: checking ttype=" + lexer.ttype + " (" + lexer.render() + ")"); + + if (lexer.ttype == lexer.TT_WORD && + lexer.sval.indexOf('.') == -1) + throw new CQLParseException("unknown first-class relation: " + + lexer.sval); + return (isProxRelation() || lexer.ttype == lexer.TT_ANY || lexer.ttype == lexer.TT_ALL || lexer.ttype == lexer.TT_EXACT || - lexer.ttype == lexer.TT_SCR); + lexer.ttype == lexer.TT_SCR || + lexer.ttype == lexer.TT_WORD); } // Checks for a relation that may be used inside a prox operator diff --git a/src/org/z3950/zing/cql/CQLRelation.java b/src/org/z3950/zing/cql/CQLRelation.java index cd0c0b9..cb2dfb6 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.10 2002-12-11 17:14:20 mike Exp $ +// $Id: CQLRelation.java,v 1.11 2003-09-04 21:56:46 mike Exp $ package org.z3950.zing.cql; import java.util.Vector; @@ -8,7 +8,7 @@ import java.lang.StringBuffer; /** * Represents a relation between a CQL qualifier and term. * - * @version $Id: CQLRelation.java,v 1.10 2002-12-11 17:14:20 mike Exp $ + * @version $Id: CQLRelation.java,v 1.11 2003-09-04 21:56:46 mike Exp $ */ public class CQLRelation extends CQLNode { ModifierSet ms; @@ -17,8 +17,9 @@ public class CQLRelation extends CQLNode { * Creates a new CQLRelation with the specified base relation. * Typical base relations include the usual six ordering relations * (<=, >, etc.), the text - * relations any, all and exact and the - * server-choice relation scr. + * relations any, all and exact, the + * server-choice relation scr and profiled relations of + * the form prefix.name. */ public CQLRelation(String base) { ms = new ModifierSet(base); -- 1.7.10.4