1 // $Id: Modifier.java,v 1.1 2007-06-27 17:01:23 mike Exp $
3 package org.z3950.zing.cql;
4 import java.util.Vector;
5 import java.lang.StringBuffer;
8 * Represents a single modifier, consisting of three elements: a type,
9 * a comparision and a value. For example, "distance", "<", "3". The
10 * type is mandatory; either the comparison and value must both occur,
13 * This class is used only by ModifierSet.
15 * @version $Id: Modifier.java,v 1.1 2007-06-27 17:01:23 mike Exp $
17 public class Modifier {
23 * Creates a new Modifier with the specified type, comparison
26 public Modifier(String type, String comparison, String value) {
28 this.comparison = comparison;
33 * Creates a new Modifier with the specified value but no
34 * comparison or value.
36 public Modifier(String value) {
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 StringBuffer buf = new StringBuffer();
64 buf.append(Utils.indent(level) + "<modifier>\n");
65 buf.append(Utils.indent(level+1) +
66 "<type>" + Utils.xq(type) + "</type>\n");
68 buf.append(Utils.indent(level+1) + "<" + relationElement + ">" +
69 Utils.xq(comparison) + "</" + relationElement + ">\n");
70 buf.append(Utils.indent(level+1) +
71 "<value>" + Utils.xq(value) + "</value>\n");
74 buf.append(Utils.indent(level) + "</modifier>\n");
75 return buf.toString();
78 public String toCQL() {
79 StringBuffer buf = new StringBuffer(type);
82 buf.append(" " + comparison + " " + value);
84 return buf.toString();