1 // $Id: Modifier.java,v 1.2 2007-06-27 17:18:54 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.2 2007-06-27 17:18:54 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;
30 //System.err.println("Made new modifier with " + "type='" + type + "', " + "comparison='" + comparison + "', " + "value='" + value + "',\n");
34 * Creates a new Modifier with the specified type but no
35 * comparison or value.
37 public Modifier(String value) {
39 //System.err.println("Made new modifier of type '" + type + "'\n");
43 * Returns the type with which the Modifier was created.
45 public String getType() {
50 * Returns the comparison with which the Modifier was created.
52 public String getComparison() {
57 * Returns the value with which the Modifier was created.
59 public String getValue() {
63 public String toXCQL(int level, String relationElement) {
64 StringBuffer buf = new StringBuffer();
66 buf.append(Utils.indent(level) + "<modifier>\n");
67 buf.append(Utils.indent(level+1) +
68 "<type>" + Utils.xq(type) + "</type>\n");
70 buf.append(Utils.indent(level+1) + "<" + relationElement + ">" +
71 Utils.xq(comparison) + "</" + relationElement + ">\n");
72 buf.append(Utils.indent(level+1) +
73 "<value>" + Utils.xq(value) + "</value>\n");
76 buf.append(Utils.indent(level) + "</modifier>\n");
77 return buf.toString();
80 public String toCQL() {
81 StringBuffer buf = new StringBuffer(type);
84 buf.append(" " + comparison + " " + value);
86 return buf.toString();