- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntField.java
More file actions
Latest commit
83 lines (65 loc) · 1.64 KB
/
Copy pathIntField.java
File metadata and controls
83 lines (65 loc) · 1.64 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
packagesimpledb;
importjava.io.*;
/**
* Instance of Field that stores a single integer.
*/
publicclassIntFieldimplementsField {
privateintvalue;
publicintgetValue() {
returnvalue;
}
/**
* Constructor.
*
* @param i The value of this field.
*/
publicIntField(inti) {
value = i;
}
publicStringtoString() {
returnInteger.toString(value);
}
publicinthashCode() {
returnvalue;
}
publicbooleanequals(Objectfield) {
return ((IntField) field).value == value;
}
publicvoidserialize(DataOutputStreamdos) throwsIOException {
dos.writeInt(value);
}
/**
* Compare the specified field to the value of this Field.
* Return semantics are as specified by Field.compare
*
* @throws IllegalCastException if val is not an IntField
* @see Field#compare
*/
publicbooleancompare(Predicate.Opop, Fieldval) {
IntFieldiVal = (IntField) val;
switch (op) {
caseEQUALS:
returnvalue == iVal.value;
caseNOT_EQUALS:
returnvalue != iVal.value;
caseGREATER_THAN:
returnvalue > iVal.value;
caseGREATER_THAN_OR_EQ:
returnvalue >= iVal.value;
caseLESS_THAN:
returnvalue < iVal.value;
caseLESS_THAN_OR_EQ:
returnvalue <= iVal.value;
caseLIKE:
returnvalue == iVal.value;
}
returnfalse;
}
/**
* Return the Type of this field.
* @return Type.INT_TYPE
*/
publicTypegetType() {
returnType.INT_TYPE;
}
}