blob: 0fb959e9dac3923858ca9c155033a0439c6732b6 (
plain) (
blame)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.datatypes;
import java.util.Map;
import java.util.TreeMap;
/**
* @author Thomas Gundersen
*/
public abstract class FieldPathIteratorHandler {
public static class IndexValue {
private int index;
private FieldValue key;
public int getIndex() {
return index;
}
public FieldValue getKey() {
return key;
}
public IndexValue() {
index = -1;
key = null;
}
public IndexValue(int index) {
this.index = index;
key = null;
}
public IndexValue(FieldValue key) {
index = -1;
this.key = key;
}
public String toString() {
if (key != null) {
return key.toString();
} else {
return "" + index;
}
}
@Override
public int hashCode() {
int hc = index;
if (key != null) {
hc = key.hashCode();
}
return hc;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof IndexValue)) {
return false;
}
IndexValue other = (IndexValue)o;
if (key != null && other.key != null) {
return key.equals(other.key);
}
if (key == null && other.key == null) {
return index == other.index;
}
return false;
}
};
public static class VariableMap extends TreeMap<String, IndexValue> {
@Override
public Object clone() {
Map<String, IndexValue> map = new VariableMap();
map.putAll(this);
return map;
}
}
private VariableMap variables = new VariableMap();
public void onPrimitive(FieldValue fv) {
}
public boolean onComplex(FieldValue fv) {
return true;
}
public ModificationStatus doModify(FieldValue fv) {
return ModificationStatus.NOT_MODIFIED;
}
public enum ModificationStatus {
MODIFIED, REMOVED, NOT_MODIFIED
}
public ModificationStatus modify(FieldValue fv) {
return doModify(fv);
}
public boolean createMissingPath() {
return false;
}
public VariableMap getVariables() {
return variables;
}
}
|