570afffd94d906969e9b29c4f37ed1bffc7b5eb0
[cql-java-moved-to-github.git] / src / main / java / org / z3950 / zing / cql / CQLRelation.java
1 // $Id: CQLRelation.java,v 1.19 2007-07-03 13:40:58 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 index and term.
10  *
11  * @version     $Id: CQLRelation.java,v 1.19 2007-07-03 13:40:58 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>, the
21      * old server-choice relation <TT>scr</TT> and profiled relations of
22      * the form <TT><I>prefix</I>.<I>name</I></TT>.
23      */
24     // ### Seems wrong: a modifier set should not have a base, a
25     // relation should
26     public CQLRelation(String base) {
27         ms = new ModifierSet(base);
28     }
29
30     /**
31      * Returns the base relation with which the CQLRelation was
32      * originally created.
33      */
34     public String getBase() {
35         return ms.getBase();
36     }
37
38     /**
39      * Sets the modifiers of the specified CQLRelation.
40      * Typical relation modifiers include <TT>relevant</TT>,
41      * <TT>fuzzy</TT>, <TT>stem</TT> and <TT>phonetic</TT>.  On the
42      * whole, these modifiers have a meaningful interpretation only
43      * for the text relations.
44      */
45     public void setModifiers(ModifierSet ms) {
46         this.ms = ms;
47     }
48
49     /**
50      * Returns an array of the modifiers associated with a CQLRelation.
51      * @return
52      *  An array of Modifier objects.
53      */
54     public Vector<Modifier> getModifiers() {
55         return ms.getModifiers();
56     }
57
58     public String toXCQL(int level, Vector prefixes, Vector sortkeys) {
59         if (sortkeys != null)
60             throw new Error("CQLRelation.toXCQL() called with sortkeys");
61
62         return ms.toXCQL(level, "relation");
63     }
64
65     public String toCQL() {
66         return ms.toCQL();
67     }
68
69     public String toPQF(Properties config) throws PQFTranslationException {
70         throw new Error("CQLRelation.toPQF() can never be called");
71     }
72
73     public byte[] toType1BER(Properties config) {
74         throw new Error("CQLRelation.toType1BER() can never be called");
75     }
76 }