- // ### There must be a better way ...
- if (quotedTerm.indexOf('"') != -1 ||
- quotedTerm.indexOf(' ') != -1 ||
- quotedTerm.indexOf('\t') != -1 ||
- quotedTerm.indexOf('=') != -1 ||
- quotedTerm.indexOf('<') != -1 ||
- quotedTerm.indexOf('>') != -1 ||
- quotedTerm.indexOf('/') != -1 ||
- quotedTerm.indexOf('(') != -1 ||
- quotedTerm.indexOf(')') != -1) {
- quotedTerm = '"' + quotedTerm + '"';
+ return res;
+ }
+
+ public String toPQF(Properties config)
+ throws UnknownQualifierException, UnknownRelationException {
+ Vector attrs = new Vector();
+
+ if (qualifier != null) {
+ String s = config.getProperty(qualifier);
+ if (s == null)
+ throw new UnknownQualifierException(qualifier);
+ attrs.add(s);
+ } else {
+ // ### get a default access point from properties?
+ }
+
+ if (relation != null) {
+ String rel = relation.getBase();
+ // ### handle "any" and "all"
+ String s = config.getProperty("cql-java.relation." + rel);
+ if (s == null)
+ throw new UnknownRelationException(rel);
+ attrs.add(s);
+ } else {
+ // ### get a default relation from properties?
+ }
+
+ // ### handle position attributes
+ // ### handle structure attributes
+ // ### handle "always" attributes
+
+ // ### should split Vector elements on spaces
+ String s = "";
+ for (int i = 0; i < attrs.size(); i++) {
+ s += "@attr " + (String) attrs.get(i) + " ";
+ }
+
+ return s + maybeQuote(term);
+ }
+
+ static String maybeQuote(String str) {
+ // There _must_ be a better way to make this test ...
+ if (str.length() == 0 ||
+ str.indexOf('"') != -1 ||
+ str.indexOf(' ') != -1 ||
+ str.indexOf('\t') != -1 ||
+ str.indexOf('=') != -1 ||
+ str.indexOf('<') != -1 ||
+ str.indexOf('>') != -1 ||
+ str.indexOf('/') != -1 ||
+ str.indexOf('(') != -1 ||
+ str.indexOf(')') != -1) {
+ str = '"' + Utils.replaceString(str, "\"", "\\\"") + '"';