X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Forg%2Fz3950%2Fzing%2Fcql%2FCQLRelation.java;h=0d986747e4ea63546d9686080737809aa2936212;hb=fc82b225d39cc66cb85c2557db0c0d4a4c5a6e27;hp=3de9f579435d7b0d1bf897c169be1487e1e6f482;hpb=70be8275aabe87c909bf11148bb279c3e1380bb2;p=cql-java-moved-to-github.git
diff --git a/src/org/z3950/zing/cql/CQLRelation.java b/src/org/z3950/zing/cql/CQLRelation.java
index 3de9f57..0d98674 100644
--- a/src/org/z3950/zing/cql/CQLRelation.java
+++ b/src/org/z3950/zing/cql/CQLRelation.java
@@ -1,76 +1,49 @@
-// $Id: CQLRelation.java,v 1.1 2002-10-30 09:19:26 mike Exp $
+// $Id: CQLRelation.java,v 1.5 2002-11-06 20:13:45 mike Exp $
package org.z3950.zing.cql;
import java.util.Vector;
+import java.util.Properties;
import java.lang.StringBuffer;
/**
* Represents a relation between a CQL qualifier and term.
- * ###
*
- * @version $Id: CQLRelation.java,v 1.1 2002-10-30 09:19:26 mike Exp $
+ * @version $Id: CQLRelation.java,v 1.5 2002-11-06 20:13:45 mike Exp $
*/
public class CQLRelation extends CQLNode {
- String base;
- Vector modifiers;
+ ModifierSet ms;
public CQLRelation(String base) {
- this.base = base;
- modifiers = new Vector();
+ ms = new ModifierSet(base);
+ }
+
+ public String getBase() {
+ return ms.getBase();
}
public void addModifier(String modifier) {
- modifiers.add(modifier);
+ ms.addModifier(null, modifier);
}
public String[] getModifiers() {
- int n = modifiers.size();
- String[] res = new String[n];
+ Vector[] v = ms.getModifiers();
+ int n = v.length;
+ String[] s = new String[n];
for (int i = 0; i < n; i++) {
- res[i] = (String) modifiers.get(i);
+ s[i] = (String) v[i].get(1);
}
-
- return res;
+ return s;
}
public String toXCQL(int level) {
- StringBuffer buf = new StringBuffer();
- buf.append (indent(level) + "\n" +
- indent(level+1) + "" + xq(base) + "\n");
- String[] mods = getModifiers();
- if (mods.length > 0) {
- buf.append(indent(level+1) + "\n");
- for (int i = 0; i < mods.length; i++)
- buf.append(indent(level+2)).
- append(""). append(mods[i]).
- append("\n");
- buf.append(indent(level+1) + "\n");
- }
- buf.append(indent(level) + "\n");
- return buf.toString();
+ return ms.toXCQL(level, "relation");
}
public String toCQL() {
- StringBuffer buf = new StringBuffer(base);
- String[] mods = getModifiers();
- for (int i = 0; i < mods.length; i++) {
- buf.append("/").append(mods[i]);
- }
-
- return buf.toString();
+ return ms.toCQL();
}
- public static void main(String[] args) {
- if (args.length < 1) {
- System.err.println("Usage: CQLRelation ...");
- System.exit(1);
- }
-
- CQLRelation res = new CQLRelation(args[0]);
- for (int i = 1; i < args.length; i++) {
- res.addModifier(args[i]);
- }
-
- System.out.println(res.toCQL());
+ public String toPQF(Properties config) throws PQFTranslationException {
+ throw new Error("CQLRelation.toPQF() can never be called");
}
}