2 package org.z3950.zing.cql;
5 * Represents a single modifier, consisting of three elements: a type,
6 * a comparision and a value. For example, "distance", "<", "3". The
7 * type is mandatory; either the comparison and value must both occur,
10 * This class is used only by ModifierSet.
13 public class Modifier {
19 * Creates a new Modifier with the specified type, comparison
22 public Modifier(String type, String comparison, String value) {
24 this.comparison = comparison;
26 //System.err.println("Made new modifier with " + "type='" + type + "', " + "comparison='" + comparison + "', " + "value='" + value + "',\n");
30 * Creates a new Modifier with the specified type but no
31 * comparison or value.
33 public Modifier(String type) {
35 //System.err.println("Made new modifier of type '" + type + "'\n");
39 * Returns the type with which the Modifier was created.
41 public String getType() {
46 * Returns the comparison with which the Modifier was created.
48 public String getComparison() {
53 * Returns the value with which the Modifier was created.
55 public String getValue() {
59 void toXCQLInternal(XCQLBuilder b, int level, String relationElement) {
60 b.indent(level).append("<modifier>\n");
61 b.indent(level + 1).append("<type>");
62 b.xq(type).append("</type>\n");
64 b.indent(level + 1).append("<").append(relationElement).append(">");
65 b.xq(comparison).append("</").append(relationElement).append(">\n");
66 b.indent(level + 1).append("<value>");
67 b.xq(value).append("</value>\n");
69 b.indent(level).append("</modifier>\n");
72 public String toCQL() {
73 StringBuilder buf = new StringBuilder(type);
75 buf.append(" ").append(comparison).append(" ").append(value);
76 return buf.toString();