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 void toXCQLInternal(XCQLBuilder b, int level, String relationElement) {
62 b.indent(level).append("<modifier>\n");
63 b.indent(level + 1).append("<type>");
64 b.xq(type).append("</type>\n");
66 b.indent(level + 1).append("<").append(relationElement).append(">");
67 b.xq(comparison).append("</").append(relationElement).append(">\n");
68 b.indent(level + 1).append("<value>");
69 b.xq(value).append("</value>\n");
71 b.indent(level).append("</modifier>\n");
74 public String toCQL() {
75 StringBuilder buf = new StringBuilder(type);
77 buf.append(" ").append(comparison).append(" ").append(value);
78 return buf.toString();