Move some code around, simplify
[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.List;
5 import java.util.Properties;
6
7 /**
8  * Represents a relation between a CQL index and term.
9  *
10  * @version     $Id: CQLRelation.java,v 1.19 2007-07-03 13:40:58 mike Exp $
11  */
12 public class CQLRelation extends CQLNode {
13     ModifierSet ms;
14
15     /**
16      * Creates a new CQLRelation with the specified base relation.
17      * Typical base relations include the usual six ordering relations
18      * (<TT>&lt;=</TT>, <TT>&gt</TT>, <I>etc.</I>), the text
19      * relations <TT>any</TT>, <TT>all</TT> and <TT>exact</TT>, the
20      * old server-choice relation <TT>scr</TT> and profiled relations of
21      * the form <TT><I>prefix</I>.<I>name</I></TT>.
22      */
23     // ### Seems wrong: a modifier set should not have a base, a
24     // relation should
25     public CQLRelation(String base) {
26         ms = new ModifierSet(base);
27     }
28
29     /**
30      * Returns the base relation with which the CQLRelation was
31      * originally created.
32      */
33     public String getBase() {
34         return ms.getBase();
35     }
36
37     /**
38      * Returns an array of the modifiers associated with a CQLRelation.
39      * @return
40      *  An array of Modifier objects.
41      */
42     public List<Modifier> getModifiers() {
43         return ms.getModifiers();
44     }
45
46     @Override
47     void toXCQLInternal(XCQLBuilder b, int level, List<CQLPrefix> prefixes,
48       List<ModifierSet> sortkeys) {
49         if (sortkeys != null)
50             throw new Error("CQLRelation.toXCQL() called with sortkeys");
51         ms.toXCQLInternal(b, level, "relation", "value");
52     }
53
54     @Override
55     public String toCQL() {
56         return ms.toCQL();
57     }
58
59     @Override
60     public String toPQF(Properties config) throws PQFTranslationException {
61         throw new Error("CQLRelation.toPQF() can never be called");
62     }
63
64     @Override
65     public byte[] toType1BER(Properties config) {
66         throw new Error("CQLRelation.toType1BER() can never be called");
67     }
68 }