1 // $Id: Modifier.java,v 1.4 2007-07-03 13:29:34 mike Exp $
3 package org.z3950.zing.cql;
6 * Represents a single modifier, consisting of three elements: a type,
7 * a comparision and a value. For example, "distance", "<", "3". The
8 * type is mandatory; either the comparison and value must both occur,
11 * This class is used only by ModifierSet.
13 * @version $Id: Modifier.java,v 1.4 2007-07-03 13:29:34 mike Exp $
15 public class Modifier {
21 * Creates a new Modifier with the specified type, comparison
24 public Modifier(String type, String comparison, String value) {
26 this.comparison = comparison;
28 //System.err.println("Made new modifier with " + "type='" + type + "', " + "comparison='" + comparison + "', " + "value='" + value + "',\n");
32 * Creates a new Modifier with the specified type but no
33 * comparison or value.
35 public Modifier(String type) {
37 //System.err.println("Made new modifier of type '" + type + "'\n");
41 * Returns the type with which the Modifier was created.
43 public String getType() {
48 * Returns the comparison with which the Modifier was created.
50 public String getComparison() {
55 * Returns the value with which the Modifier was created.
57 public String getValue() {
61 public String toXCQL(int level, String relationElement) {
62 StringBuilder buf = new StringBuilder();
64 buf.append(Utils.indent(level)).append("<modifier>\n").
65 append(Utils.indent(level + 1)).append("<type>").
66 append(Utils.xq(type)).append("</type>\n");
68 buf.append(Utils.indent(level + 1)).append("<").
69 append(relationElement).append(">").
70 append(Utils.xq(comparison)).append("</").
71 append(relationElement).append(">\n").
72 append(Utils.indent(level + 1)).append("<value>").
73 append(Utils.xq(value)).append("</value>\n");
75 buf.append(Utils.indent(level)).append("</modifier>\n");
76 return buf.toString();
79 public String toCQL() {
80 StringBuilder buf = new StringBuilder(type);
82 buf.append(" ").append(comparison).append(" ").append(value);
83 return buf.toString();