Change obsolete collections, remove redundant imports
[cql-java-moved-to-github.git] / src / main / java / org / z3950 / zing / cql / CQLParser.java
index dab0e80..0503977 100644 (file)
@@ -2,11 +2,12 @@
 
 package org.z3950.zing.cql;
 import java.io.IOException;
-import java.util.Vector;
 import java.util.Properties;
 import java.io.InputStream;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
@@ -19,9 +20,9 @@ import java.io.FileNotFoundException;
 public class CQLParser {
     private CQLLexer lexer;
     private int compat;        // When false, implement CQL 1.2
-    public static int V1POINT1 = 12368;
-    public static int V1POINT2 = 12369;
-    public static int V1POINT1SORT = 12370;
+    public static final int V1POINT1 = 12368;
+    public static final int V1POINT2 = 12369;
+    public static final int V1POINT1SORT = 12370;
 
     static private boolean DEBUG = false;
     static private boolean LEXDEBUG = false;
@@ -192,7 +193,12 @@ public class CQLParser {
 
            debug("non-parenthesised term");
            word = matchSymbol("index or term");
-           if (!isSymbolicRelation() && lexer.ttype != lexer.TT_WORD)
+            while (lexer.ttype == lexer.TT_WORD && !isRelation()) {
+              word = word + " " + lexer.sval;
+              match(lexer.TT_WORD);
+            }
+
+           if (!isRelation())
                break;
 
            index = word;
@@ -201,7 +207,7 @@ public class CQLParser {
            relation = new CQLRelation(relstr);
            match(lexer.ttype);
            ModifierSet ms = gatherModifiers(relstr);
-           relation.setModifiers(ms);
+           relation.ms = ms;
            debug("index='" + index + ", " +
                  "relation='" + relation.toCQL() + "'");
        }
@@ -235,10 +241,14 @@ public class CQLParser {
        debug("isRelation: checking ttype=" + lexer.ttype +
              " (" + lexer.render() + ")");
         if (lexer.ttype == lexer.TT_WORD &&
-            (lexer.sval == "exact" ||
-             lexer.sval == "any" ||
-             lexer.sval == "all" ||
-             (lexer.sval == "scr" && compat == V1POINT2)))
+            (lexer.sval.indexOf('.') >= 0 ||
+             lexer.sval.equals("any") ||
+             lexer.sval.equals("all") ||
+             lexer.sval.equals("within") ||
+             lexer.sval.equals("encloses") ||
+             lexer.sval.equals("exact") ||
+             (lexer.sval.equals("scr") && compat != V1POINT2) ||
+             (lexer.sval.equals("adj") && compat == V1POINT2)))
           return true;
 
         return isSymbolicRelation();
@@ -360,7 +370,7 @@ public class CQLParser {
        char mode = 'x';        // x=XCQL, c=CQL, p=PQF
        String pfile = null;
 
-       Vector<String> argv = new Vector<String>();
+       List<String> argv = new ArrayList<String>();
        for (int i = 0; i < args.length; i++) {
            argv.add(args[i]);
        }