From: mike Date: Fri, 29 Nov 2002 16:43:23 +0000 (+0000) Subject: Support Adam's new position configuration elements X-Git-Tag: v1.5~180 X-Git-Url: http://jsfdemo.indexdata.com/?a=commitdiff_plain;h=5d114bb3f03898f2aae571affe49c572f5b3f5ac;p=cql-java-moved-to-github.git Support Adam's new position configuration elements --- diff --git a/src/org/z3950/zing/cql/CQLTermNode.java b/src/org/z3950/zing/cql/CQLTermNode.java index 0f9d3a9..b5244d2 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.10 2002-11-20 15:38:27 mike Exp $ +// $Id: CQLTermNode.java,v 1.11 2002-11-29 16:43:23 mike Exp $ package org.z3950.zing.cql; import java.util.Properties; @@ -12,7 +12,7 @@ import java.util.Vector; * these must be provided - you can't have a qualifier without a * relation or vice versa. * - * @version $Id: CQLTermNode.java,v 1.10 2002-11-20 15:38:27 mike Exp $ + * @version $Id: CQLTermNode.java,v 1.11 2002-11-29 16:43:23 mike Exp $ */ public class CQLTermNode extends CQLNode { private String qualifier; @@ -59,7 +59,18 @@ public class CQLTermNode extends CQLNode { public String toPQF(Properties config) throws PQFTranslationException { Vector attrs = new Vector(); - String attr; + // Do this first so that if any other truncation or + // completeness attributes are generated, they "overwrite" + // those specified here. + // + // ### This approach relies on an unpleasant detail of Index + // Data's (admittedly definitive) implementation of PQF, + // and should not relied upon. + // + String attr = config.getProperty("always"); + if (attr != null) + attrs.add(attr); + attr = config.getProperty("qualifier." + qualifier); if (attr == null) throw new UnknownQualifierException(qualifier); @@ -89,12 +100,27 @@ public class CQLTermNode extends CQLNode { attrs.add(attr); } - String pos = "unanchored"; + String pos = "any"; String text = term; + //System.err.println("before check: text='" + text + "'"); if (text.length() > 0 && text.substring(0, 1).equals("^")) { + //System.err.println("first in field"); text = text.substring(1); - pos = "anchored"; + pos = "first"; + } + //System.err.println("between checks: text='" + text + "'"); + int len = text.length(); + if (len > 0 && text.substring(len-1, len).equals("^")) { + //System.err.println("last in field"); + text = text.substring(0, len-1); + pos = pos.equals("first") ? "firstAndLast" : "last"; + // ### in the firstAndLast case, the standard + // pqf.properties file specifies that we generate a + // completeness=whole-field attributem, which means that + // we don't generate a position attribute at all. Do we + // care? Does it matter? } + //System.err.println("after checks: text='" + text + "'"); attr = config.getProperty("position." + pos); if (attr == null) throw new UnknownPositionException(pos); @@ -105,10 +131,6 @@ public class CQLTermNode extends CQLNode { attr = config.getProperty("structure.*"); attrs.add(attr); - attr = config.getProperty("always"); - if (attr != null) - attrs.add(attr); - String s = ""; for (int i = 0; i < attrs.size(); i++) { attr = (String) attrs.get(i);