1 /*
2 * Copyright 2009-2013 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.orangesignal.csv.filters;
18
19 import java.util.List;
20 import java.util.regex.Pattern;
21
22 /**
23 * DSL (Domain Specific Language) 形式でスマートなフィルタ条件の定義が可能な {@link CsvNamedValueFilter} の実装クラスを提供します。
24 *
25 * @author Koji Sugisawa
26 * @since 1.2.3
27 */
28 public class SimpleCsvNamedValueFilter implements CsvNamedValueFilter {
29
30 private CsvNamedValueLogicalExpression expr;
31
32 /**
33 * デフォルトコンストラクタです。
34 */
35 public SimpleCsvNamedValueFilter() {
36 this(new CsvNamedValueAndExpression());
37 }
38
39 /**
40 * コンストラクタです。
41 *
42 * @param expr 区切り文字形式データフィルタ
43 * @throws IllegalArgumentException <code>expr</code> が <code>null</code> の場合
44 */
45 public SimpleCsvNamedValueFilter(final CsvNamedValueLogicalExpression expr) {
46 if (expr == null) {
47 throw new IllegalArgumentException(String.format("%s must not be null", CsvNamedValueLogicalExpression.class.getSimpleName()));
48 }
49 this.expr = expr;
50 }
51
52 /**
53 * 指定された区切り文字形式データの項目名リストと値リストでフィルタする区切り文字形式データフィルタを追加します。
54 *
55 * @param filter 区切り文字形式データフィルタ
56 * @return このオブジェクトへの参照
57 */
58 public SimpleCsvNamedValueFilter add(final CsvNamedValueFilter filter) {
59 expr.add(filter);
60 return this;
61 }
62
63 /**
64 * 指定された項目位置に対応する区切り文字形式データの値が <code>null</code> であるかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
65 *
66 * @param position 項目位置
67 * @return このオブジェクトへの参照
68 */
69 public SimpleCsvNamedValueFilter isNull(final int position) {
70 expr.add(CsvExpressions.isNull(position));
71 return this;
72 }
73
74 /**
75 * 指定された項目名に対応する区切り文字形式データの値が <code>null</code> であるかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
76 *
77 * @param name 項目名
78 * @return このオブジェクトへの参照
79 * @throws IllegalArgumentException <code>name</code> が <code>null</code> の場合
80 */
81 public SimpleCsvNamedValueFilter isNull(final String name) {
82 expr.add(CsvExpressions.isNull(name));
83 return this;
84 }
85
86 /**
87 * 指定された項目位置に対応する区切り文字形式データの値が <code>null</code> でないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
88 *
89 * @param position 項目位置
90 * @return このオブジェクトへの参照
91 */
92 public SimpleCsvNamedValueFilter isNotNull(final int position) {
93 expr.add(CsvExpressions.isNotNull(position));
94 return this;
95 }
96
97 /**
98 * 指定された項目名に対応する区切り文字形式データの値が <code>null</code> でないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
99 *
100 * @param name 項目名
101 * @return このオブジェクトへの参照
102 * @throws IllegalArgumentException <code>name</code> が <code>null</code> の場合
103 */
104 public SimpleCsvNamedValueFilter isNotNull(final String name) {
105 expr.add(CsvExpressions.isNotNull(name));
106 return this;
107 }
108
109 /**
110 * 指定された項目位置に対応する区切り文字形式データの値が空かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
111 *
112 * @param position 項目位置
113 * @return このオブジェクトへの参照
114 */
115 public SimpleCsvNamedValueFilter isEmpty(final int position) {
116 expr.add(CsvExpressions.isEmpty(position));
117 return this;
118 }
119
120 /**
121 * 指定された項目名に対応する区切り文字形式データの値が空かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
122 *
123 * @param name 項目名
124 * @return このオブジェクトへの参照
125 */
126 public SimpleCsvNamedValueFilter isEmpty(final String name) {
127 expr.add(CsvExpressions.isEmpty(name));
128 return this;
129 }
130
131 /**
132 * 指定された項目位置に対応する区切り文字形式データの値が空でないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
133 *
134 * @param position 項目位置
135 * @return このオブジェクトへの参照
136 */
137 public SimpleCsvNamedValueFilter isNotEmpty(final int position) {
138 expr.add(CsvExpressions.isNotEmpty(position));
139 return this;
140 }
141
142 /**
143 * 指定された項目名に対応する区切り文字形式データの値が空でないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
144 *
145 * @param name 項目名
146 * @return このオブジェクトへの参照
147 */
148 public SimpleCsvNamedValueFilter isNotEmpty(final String name) {
149 expr.add(CsvExpressions.isNotEmpty(name));
150 return this;
151 }
152
153 /**
154 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値と等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
155 *
156 * @param position 項目位置
157 * @param criteria 判定基準値
158 * @return このオブジェクトへの参照
159 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
160 */
161 public SimpleCsvNamedValueFilter eq(final int position, final String criteria) {
162 expr.add(CsvExpressions.eq(position, criteria));
163 return this;
164 }
165
166 /**
167 * 指定された項目名に対応する区切り文字形式データの値が判定基準値と等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
168 *
169 * @param name 項目名
170 * @param criteria 判定基準値
171 * @return このオブジェクトへの参照
172 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
173 */
174 public SimpleCsvNamedValueFilter eq(final String name, final String criteria) {
175 expr.add(CsvExpressions.eq(name, criteria));
176 return this;
177 }
178
179 /**
180 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値と等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
181 *
182 * @param position 項目位置
183 * @param criteria 判定基準値
184 * @param ignoreCase 大文字と小文字を区別するかどうか
185 * @return このオブジェクトへの参照
186 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
187 */
188 public SimpleCsvNamedValueFilter eq(final int position, final String criteria, final boolean ignoreCase) {
189 expr.add(CsvExpressions.eq(position, criteria, ignoreCase));
190 return this;
191 }
192
193 /**
194 * 指定された項目名に対応する区切り文字形式データの値が判定基準値と等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
195 *
196 * @param name 項目名
197 * @param criteria 判定基準値
198 * @param ignoreCase 大文字と小文字を区別するかどうか
199 * @return このオブジェクトへの参照
200 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
201 */
202 public SimpleCsvNamedValueFilter eq(final String name, final String criteria, final boolean ignoreCase) {
203 expr.add(CsvExpressions.eq(name, criteria, ignoreCase));
204 return this;
205 }
206
207 /**
208 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値と等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
209 *
210 * @param position 項目位置
211 * @param criteria 判定基準値
212 * @return このオブジェクトへの参照
213 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
214 */
215 public SimpleCsvNamedValueFilter ne(final int position, final String criteria) {
216 expr.add(CsvExpressions.ne(position, criteria));
217 return this;
218 }
219
220 /**
221 * 指定された項目名に対応する区切り文字形式データの値が判定基準値と等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
222 *
223 * @param name 項目名
224 * @param criteria 判定基準値
225 * @return このオブジェクトへの参照
226 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
227 */
228 public SimpleCsvNamedValueFilter ne(final String name, final String criteria) {
229 expr.add(CsvExpressions.ne(name, criteria));
230 return this;
231 }
232
233 /**
234 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値と等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
235 *
236 * @param position 項目位置
237 * @param criteria 判定基準値
238 * @param ignoreCase 大文字と小文字を区別するかどうか
239 * @return このオブジェクトへの参照
240 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
241 */
242 public SimpleCsvNamedValueFilter ne(final int position, final String criteria, final boolean ignoreCase) {
243 expr.add(CsvExpressions.ne(position, criteria, ignoreCase));
244 return this;
245 }
246
247 /**
248 * 指定された項目名に対応する区切り文字形式データの値が判定基準値と等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
249 *
250 * @param name 項目名
251 * @param criteria 判定基準値
252 * @param ignoreCase 大文字と小文字を区別するかどうか
253 * @return このオブジェクトへの参照
254 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
255 */
256 public SimpleCsvNamedValueFilter ne(final String name, final String criteria, final boolean ignoreCase) {
257 expr.add(CsvExpressions.ne(name, criteria, ignoreCase));
258 return this;
259 }
260
261 /**
262 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値群のいずれかと等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
263 *
264 * @param position 項目位置
265 * @param criterias 判定基準値群
266 * @return このオブジェクトへの参照
267 * @throws IllegalArgumentException <code>criterias</code> が <code>null</code> の場合
268 */
269 public SimpleCsvNamedValueFilter in(final int position, final String... criterias) {
270 expr.add(CsvExpressions.in(position, criterias));
271 return this;
272 }
273
274 /**
275 * 指定された項目名に対応する区切り文字形式データの値が判定基準値群のいずれかと等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
276 *
277 * @param name 項目名
278 * @param criterias 判定基準値群
279 * @return このオブジェクトへの参照
280 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
281 */
282 public SimpleCsvNamedValueFilter in(final String name, final String... criterias) {
283 expr.add(CsvExpressions.in(name, criterias));
284 return this;
285 }
286
287 /**
288 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値群のいずれかと等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
289 *
290 * @param position 項目位置
291 * @param criterias 判定基準値群
292 * @param ignoreCase 大文字と小文字を区別するかどうか
293 * @return このオブジェクトへの参照
294 * @throws IllegalArgumentException <code>criterias</code> が <code>null</code> の場合
295 */
296 public SimpleCsvNamedValueFilter in(final int position, final String[] criterias, final boolean ignoreCase) {
297 expr.add(CsvExpressions.in(position, criterias, ignoreCase));
298 return this;
299 }
300
301 /**
302 * 指定された項目名に対応する区切り文字形式データの値が判定基準値群のいずれかと等しいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
303 *
304 * @param name 項目名
305 * @param criterias 判定基準値群
306 * @param ignoreCase 大文字と小文字を区別するかどうか
307 * @return このオブジェクトへの参照
308 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
309 */
310 public SimpleCsvNamedValueFilter in(final String name, final String[] criterias, final boolean ignoreCase) {
311 expr.add(CsvExpressions.in(name, criterias, ignoreCase));
312 return this;
313 }
314
315 /**
316 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値群のいずれとも等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
317 *
318 * @param position 項目位置
319 * @param criterias 判定基準値群
320 * @return このオブジェクトへの参照
321 * @throws IllegalArgumentException <code>criterias</code> が <code>null</code> の場合
322 */
323 public SimpleCsvNamedValueFilter notIn(final int position, final String... criterias) {
324 expr.add(CsvExpressions.notIn(position, criterias));
325 return this;
326 }
327
328 /**
329 * 指定された項目名に対応する区切り文字形式データの値が判定基準値群のいずれとも等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
330 *
331 * @param name 項目名
332 * @param criterias 判定基準値群
333 * @return このオブジェクトへの参照
334 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
335 */
336 public SimpleCsvNamedValueFilter notIn(final String name, final String... criterias) {
337 expr.add(CsvExpressions.notIn(name, criterias));
338 return this;
339 }
340
341 /**
342 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値群のいずれとも等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
343 *
344 * @param position 項目位置
345 * @param criterias 判定基準値群
346 * @param ignoreCase 大文字と小文字を区別するかどうか
347 * @return このオブジェクトへの参照
348 * @throws IllegalArgumentException <code>criterias</code> が <code>null</code> の場合
349 */
350 public SimpleCsvNamedValueFilter notIn(final int position, final String[] criterias, final boolean ignoreCase) {
351 expr.add(CsvExpressions.notIn(position, criterias, ignoreCase));
352 return this;
353 }
354
355 /**
356 * 指定された項目名に対応する区切り文字形式データの値が判定基準値群のいずれとも等しくないかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
357 *
358 * @param name 項目名
359 * @param criterias 判定基準値群
360 * @param ignoreCase 大文字と小文字を区別するかどうか
361 * @return このオブジェクトへの参照
362 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
363 */
364 public SimpleCsvNamedValueFilter notIn(final String name, final String[] criterias, final boolean ignoreCase) {
365 expr.add(CsvExpressions.notIn(name, criterias, ignoreCase));
366 return this;
367 }
368
369 /**
370 * 指定された項目位置に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
371 *
372 * @param position 項目位置
373 * @param pattern 正規表現パターン
374 * @return このオブジェクトへの参照
375 * @throws IllegalArgumentException <code>pattern</code> が <code>null</code> の場合
376 */
377 public SimpleCsvNamedValueFilter regex(final int position, final String pattern) {
378 expr.add(CsvExpressions.regex(position, pattern));
379 return this;
380 }
381
382 /**
383 * 指定された項目名に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
384 *
385 * @param name 項目名
386 * @param pattern 正規表現パターン
387 * @return このオブジェクトへの参照
388 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
389 */
390 public SimpleCsvNamedValueFilter regex(final String name, final String pattern) {
391 expr.add(CsvExpressions.regex(name, pattern));
392 return this;
393 }
394
395 /**
396 * 指定された項目位置に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
397 *
398 * @param position 項目位置
399 * @param pattern 正規表現パターン
400 * @param ignoreCase 大文字と小文字を区別するかどうか
401 * @return このオブジェクトへの参照
402 * @throws IllegalArgumentException <code>pattern</code> が <code>null</code> の場合
403 */
404 public SimpleCsvNamedValueFilter regex(final int position, final String pattern, final boolean ignoreCase) {
405 expr.add(CsvExpressions.regex(position, pattern, ignoreCase));
406 return this;
407 }
408
409 /**
410 * 指定された項目名に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
411 *
412 * @param name 項目名
413 * @param pattern 正規表現パターン
414 * @param ignoreCase 大文字と小文字を区別するかどうか
415 * @return このオブジェクトへの参照
416 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
417 */
418 public SimpleCsvNamedValueFilter regex(final String name, final String pattern, final boolean ignoreCase) {
419 expr.add(CsvExpressions.regex(name, pattern, ignoreCase));
420 return this;
421 }
422
423 /**
424 * 指定された項目位置に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
425 *
426 * @param position 項目位置
427 * @param pattern 正規表現パターン
428 * @param flags マッチフラグ
429 * @return このオブジェクトへの参照
430 * @throws IllegalArgumentException <code>pattern</code> が <code>null</code> の場合
431 */
432 public SimpleCsvNamedValueFilter regex(final int position, final String pattern, final int flags) {
433 expr.add(CsvExpressions.regex(position, pattern, flags));
434 return this;
435 }
436
437 /**
438 * 指定された項目名に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
439 *
440 * @param name 項目名
441 * @param pattern 正規表現パターン
442 * @param flags マッチフラグ
443 * @return このオブジェクトへの参照
444 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
445 */
446 public SimpleCsvNamedValueFilter regex(final String name, final String pattern, final int flags) {
447 expr.add(CsvExpressions.regex(name, pattern, flags));
448 return this;
449 }
450
451 /**
452 * 指定された項目位置に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
453 *
454 * @param position 項目位置
455 * @param pattern 正規表現パターン
456 * @return このオブジェクトへの参照
457 * @throws IllegalArgumentException <code>pattern</code> が <code>null</code> の場合
458 */
459 public SimpleCsvNamedValueFilter regex(final int position, final Pattern pattern) {
460 expr.add(CsvExpressions.regex(position, pattern));
461 return this;
462 }
463
464 /**
465 * 指定された項目名に対応する区切り文字形式データの値が正規表現パターンとマッチするかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
466 *
467 * @param name 項目名
468 * @param pattern 正規表現パターン
469 * @return このオブジェクトへの参照
470 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
471 */
472 public SimpleCsvNamedValueFilter regex(final String name, final Pattern pattern) {
473 expr.add(CsvExpressions.regex(name, pattern));
474 return this;
475 }
476
477 /**
478 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値より大きいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
479 *
480 * @param position 項目位置
481 * @param criteria 判定基準値
482 * @return このオブジェクトへの参照
483 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
484 */
485 public SimpleCsvNamedValueFilter gt(final int position, final String criteria) {
486 expr.add(CsvExpressions.gt(position, criteria));
487 return this;
488 }
489
490 /**
491 * 指定された項目名に対応する区切り文字形式データの値が判定基準値より大きいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
492 *
493 * @param name 項目名
494 * @param criteria 判定基準値
495 * @return このオブジェクトへの参照
496 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
497 */
498 public SimpleCsvNamedValueFilter gt(final String name, final String criteria) {
499 expr.add(CsvExpressions.gt(name, criteria));
500 return this;
501 }
502
503 /**
504 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値より小さいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
505 *
506 * @param position 項目位置
507 * @param criteria 判定基準値
508 * @return このオブジェクトへの参照
509 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
510 */
511 public SimpleCsvNamedValueFilter lt(final int position, final String criteria) {
512 expr.add(CsvExpressions.lt(position, criteria));
513 return this;
514 }
515
516 /**
517 * 指定された項目名に対応する区切り文字形式データの値が判定基準値より小さいかどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
518 *
519 * @param name 項目名
520 * @param criteria 判定基準値
521 * @return このオブジェクトへの参照
522 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
523 */
524 public SimpleCsvNamedValueFilter lt(final String name, final String criteria) {
525 expr.add(CsvExpressions.lt(name, criteria));
526 return this;
527 }
528
529 /**
530 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値以上かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
531 *
532 * @param position 項目位置
533 * @param criteria 判定基準値
534 * @return このオブジェクトへの参照
535 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
536 */
537 public SimpleCsvNamedValueFilter ge(final int position, final String criteria) {
538 expr.add(CsvExpressions.ge(position, criteria));
539 return this;
540 }
541
542 /**
543 * 指定された項目名に対応する区切り文字形式データの値が判定基準値以上かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
544 *
545 * @param name 項目名
546 * @param criteria 判定基準値
547 * @return このオブジェクトへの参照
548 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
549 */
550 public SimpleCsvNamedValueFilter ge(final String name, final String criteria) {
551 expr.add(CsvExpressions.ge(name, criteria));
552 return this;
553 }
554
555 /**
556 * 指定された項目位置に対応する区切り文字形式データの値が判定基準値以下かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
557 *
558 * @param position 項目位置
559 * @param criteria 判定基準値
560 * @return このオブジェクトへの参照
561 * @throws IllegalArgumentException <code>criteria</code> が <code>null</code> の場合
562 */
563 public SimpleCsvNamedValueFilter le(final int position, final String criteria) {
564 expr.add(CsvExpressions.le(position, criteria));
565 return this;
566 }
567
568 /**
569 * 指定された項目名に対応する区切り文字形式データの値が判定基準値以下かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
570 *
571 * @param name 項目名
572 * @param criteria 判定基準値
573 * @return このオブジェクトへの参照
574 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
575 */
576 public SimpleCsvNamedValueFilter le(final String name, final String criteria) {
577 expr.add(CsvExpressions.le(name, criteria));
578 return this;
579 }
580
581 /**
582 * 指定された項目位置に対応する区切り文字形式データの値が下限値から上限値の範囲かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
583 *
584 * @param position 項目位置
585 * @param low 下限値
586 * @param high 上限値
587 * @return このオブジェクトへの参照
588 * @throws IllegalArgumentException <code>low</code> または <code>high</code> が <code>null</code> の場合
589 */
590 public SimpleCsvNamedValueFilter between(final int position, final String low, final String high) {
591 expr.add(CsvExpressions.between(position, low, high));
592 return this;
593 }
594
595 /**
596 * 指定された項目名に対応する区切り文字形式データの値が下限値から上限値の範囲かどうかでフィルタを適用する区切り文字形式データフィルタを追加します。
597 *
598 * @param name 項目名
599 * @param low 下限値
600 * @param high 上限値
601 * @return このオブジェクトへの参照
602 * @throws IllegalArgumentException パラメータが <code>null</code> の場合
603 */
604 public SimpleCsvNamedValueFilter between(final String name, final String low, final String high) {
605 expr.add(CsvExpressions.between(name, low, high));
606 return this;
607 }
608
609 /**
610 * 指定された区切り文字形式データの項目名リストと値リストでフィルタする区切り文字形式データフィルタの論理否定でフィルタを適用する区切り文字形式データフィルタを追加します。
611 *
612 * @param filter 論理否定する区切り文字形式データフィルタ
613 * @return このオブジェクトへの参照
614 * @throws IllegalArgumentException <code>filter</code> が <code>null</code> の場合
615 */
616 public SimpleCsvNamedValueFilter not(final CsvNamedValueFilter filter) {
617 expr.add(CsvExpressions.not(filter));
618 return this;
619 }
620
621 @Override
622 public boolean accept(final List<String> header, final List<String> values) {
623 return expr.accept(header, values);
624 }
625
626 @Override
627 public String toString() {
628 final String name = getClass().getName();
629 final int period = name.lastIndexOf('.');
630 return period > 0 ? name.substring(period + 1) : name;
631 }
632
633 }