Rename the toType1() method to the more explicit toType1BER()
[cql-java-moved-to-github.git] / src / org / z3950 / zing / cql / CQLRelation.java
1 // $Id: CQLRelation.java,v 1.10 2002-12-11 17:14:20 mike Exp $
2
3 package org.z3950.zing.cql;
4 import java.util.Vector;
5 import java.util.Properties;
6 import java.lang.StringBuffer;
7
8 /**
9  * Represents a relation between a CQL qualifier and term.
10  *
11  * @version     $Id: CQLRelation.java,v 1.10 2002-12-11 17:14:20 mike Exp $
12  */
13 public class CQLRelation extends CQLNode {
14     ModifierSet ms;
15
16     /**
17      * Creates a new CQLRelation with the specified base relation.
18      * Typical base relations include the usual six ordering relations
19      * (<TT>&lt;=</TT>, <TT>&gt</TT>, <I>etc.</I>), the text
20      * relations <TT>any</TT>, <TT>all</TT> and <TT>exact</TT> and the
21      * server-choice relation <TT>scr</TT>.
22      */
23     public CQLRelation(String base) {
24         ms = new ModifierSet(base);
25     }
26
27     /**
28      * Returns the base relation with which the CQLRelation was
29      * originally created.
30      */
31     public String getBase() {
32         return ms.getBase();
33     }
34
35     /**
36      * Adds a new relation modifier to the specified CQLRelation.
37      * Typical relation modifiers include <TT>relevant</TT>,
38      * <TT>fuzzy</TT>, <TT>stem</TT> and <TT>phonetic</TT>.  On the
39      * whole, these modifiers have a meaningful interpretation only
40      * for the text relations.
41      */
42     public void addModifier(String modifier) {
43         ms.addModifier(null, modifier);
44     }
45
46     /**
47      * Returns an array of the modifiers associated with a CQLRelation.
48      * @return
49      *  An array of zero or more <TT>String</TT>s, each representing a
50      *  modifier associated with the specified CQLRelation.
51      */
52     public String[] getModifiers() {
53         Vector[] v = ms.getModifiers();
54         int n = v.length;
55         String[] s = new String[n];
56         for (int i = 0; i < n; i++) {
57             s[i] = (String) v[i].get(1);
58         }
59         return s;
60     }
61
62     public String toXCQL(int level, Vector prefixes) {
63         return ms.toXCQL(level, "relation");
64     }
65
66     public String toCQL() {
67         return ms.toCQL();
68     }
69
70     public String toPQF(Properties config) throws PQFTranslationException {
71         throw new Error("CQLRelation.toPQF() can never be called");
72     }
73
74     public byte[] toType1BER(Properties config) {
75         throw new Error("CQLRelation.toType1BER() can never be called");
76     }
77 }