-// $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;
* 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;
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);
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);
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);