-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathModifier.java
More file actions
92 lines (80 loc) · 2.34 KB
/
Modifier.java
File metadata and controls
92 lines (80 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package org.z3950.zing.cql;
/**
* Represents a single modifier, consisting of three elements: a type,
* a comparision and a value. For example, "distance", "<", "3". The
* type is mandatory; either the comparison and value must both occur,
* or neither must.
* <P>
* This class is used only by ModifierSet.
*
*/
public class Modifier {
String type;
String comparison;
String value;
private int start, stop;
/**
* Creates a new Modifier with the specified type, comparison
* and value.
*/
public Modifier(String type, String comparison, String value) {
this.type = type;
this.comparison = comparison;
this.value = value;
//System.err.println("Made new modifier with " + "type='" + type + "', " + "comparison='" + comparison + "', " + "value='" + value + "',\n");
}
/**
* Creates a new Modifier with the specified type but no
* comparison or value.
*/
public Modifier(String type) {
this.type = type;
//System.err.println("Made new modifier of type '" + type + "'\n");
}
/**
* Returns the type with which the Modifier was created.
*/
public String getType() {
return type;
}
/**
* Returns the comparison with which the Modifier was created.
*/
public String getComparison() {
return comparison;
}
/**
* Returns the value with which the Modifier was created.
*/
public String getValue() {
return value;
}
public int getStart() {
return start;
}
public int getStop() {
return stop;
}
protected void setStartStop(int start, int stop) {
this.start = start;
this.stop = stop;
}
void toXCQLInternal(XCQLBuilder b, int level, String relationElement) {
b.indent(level).append("<modifier>\n");
b.indent(level + 1).append("<type>");
b.xq(type).append("</type>\n");
if (value != null) {
b.indent(level + 1).append("<").append(relationElement).append(">");
b.xq(comparison).append("</").append(relationElement).append(">\n");
b.indent(level + 1).append("<value>");
b.xq(value).append("</value>\n");
}
b.indent(level).append("</modifier>\n");
}
public String toCQL() {
StringBuilder buf = new StringBuilder(type);
if (value != null)
buf.append(" ").append(comparison).append(" ").append(value);
return buf.toString();
}
}