1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.student.core.assembly.data;
20
21 import java.util.ArrayList;
22 import java.util.Collection;
23
24 import org.kuali.student.core.assembly.data.Data.Key;
25
26
27
28
29 public class QueryPath extends ArrayList<Key> {
30
31 private static final PathParser parser = new DefaultPathParser();
32
33 private static final long serialVersionUID = 1L;
34
35 public static String getWildCard() {
36 return parser.getWildCard();
37 }
38
39 public static String getPathSeparator(){
40 return parser.getPathSeparator();
41 }
42
43 public static QueryPath parse(final String path) {
44 return parser.parse(path);
45 }
46
47 private String stringPath = null;
48
49
50
51
52 @Override
53 public void add(final int index, final Key element) {
54 stringPath = null;
55 super.add(index, element);
56 }
57
58
59
60
61 @Override
62 public boolean add(final Key e) {
63 stringPath = null;
64 return super.add(e);
65 }
66
67
68
69
70 @Override
71 public boolean addAll(final Collection<? extends Key> c) {
72 stringPath = null;
73 return super.addAll(c);
74 }
75
76
77
78
79 @Override
80 public boolean addAll(final int index, final Collection<? extends Key> c) {
81 stringPath = null;
82 return super.addAll(index, c);
83 }
84
85
86
87
88 @Override
89 public void clear() {
90 stringPath = null;
91 super.clear();
92 }
93
94
95
96
97 @Override
98 public Key remove(final int index) {
99 stringPath = null;
100 return super.remove(index);
101 }
102
103
104
105
106 @Override
107 public boolean remove(final Object o) {
108 stringPath = null;
109 return super.remove(o);
110 }
111
112
113
114
115 @Override
116 public boolean removeAll(final Collection<?> c) {
117 stringPath = null;
118 return super.removeAll(c);
119 }
120
121
122
123
124 @Override
125 protected void removeRange(final int fromIndex, final int toIndex) {
126 stringPath = null;
127 super.removeRange(fromIndex, toIndex);
128 }
129
130
131
132
133 @Override
134 public boolean retainAll(final Collection<?> c) {
135 stringPath = null;
136 return super.retainAll(c);
137 }
138
139
140
141
142 @Override
143 public Key set(final int index, final Key element) {
144 stringPath = null;
145 return super.set(index, element);
146 }
147
148 public QueryPath subPath(final int fromIndex, final int toIndex) {
149
150 final QueryPath result = new QueryPath();
151 for (int i = fromIndex; i < toIndex; i++) {
152 result.add(this.get(i));
153 }
154 return result;
155 }
156
157 @Override
158 public String toString() {
159 if (stringPath == null) {
160 stringPath = parser.format(this);
161 }
162 return stringPath;
163 }
164
165 public static QueryPath concat(String... paths) {
166 QueryPath result = new QueryPath();
167 for (String path : paths) {
168 if (path != null) {
169 result.addAll(QueryPath.parse(path));
170 }
171 }
172 return result;
173 }
174 }