1 | class NoneSelector extends BaseSelectorContainer {↵ | | 1 | class OrSelector extends BaseSelectorContainer {↵
|
|
2 | /**↵ | | 2 | /**↵
|
3 | * Default constructor.↵ | | 3 | * Default constructor.↵
|
4 | */↵ | | 4 | */↵
|
5 | public NoneSelector() {↵ | | 5 | public OrSelector() {↵
|
6 | }↵ | | 6 | }↵
|
|
7 | /**↵ | | 7 | /**↵
|
8 | * @return a string representation of the selector↵ | | 8 | * @return a string representation of the selector↵
|
9 | */↵ | | 9 | */↵
|
10 | public String toString() {↵ | | 10 | public String toString() {↵
|
11 | StringBuffer buf = new StringBuffer();↵ | | 11 | StringBuffer buf = new StringBuffer();↵
|
12 | if (hasSelectors()) {↵ | | 12 | if (hasSelectors()) {↵
|
13 | buf.append("{noneselect: ");↵ | | 13 | buf.append("{orselect: ");↵
|
14 | buf.append(super.toString());↵ | | 14 | buf.append(super.toString());↵
|
15 | buf.append("}");↵ | | 15 | buf.append("}");↵
|
16 | }↵ | | 16 | }↵
|
17 | return buf.toString();↵ | | 17 | return buf.toString();↵
|
18 | }↵ | | 18 | }↵
|
|
19 | /**↵ | | 19 | /**↵
|
20 | * Returns true (the file is selected) only if all other selectors↵ | | 20 | * Returns true (the file is selected) if any of the other selectors↵
|
21 | * agree that the file should not be selected.↵ | | 21 | * agree that the file should be selected.↵
|
22 | *↵ | | 22 | *↵
|
23 | * @param basedir the base directory the scan is being done from↵ | | 23 | * @param basedir the base directory the scan is being done from↵
|
24 | * @param filename is the name of the file to check↵ | | 24 | * @param filename the name of the file to check↵
|
25 | * @param file is a java.io.File object for the filename that the selector↵ | | 25 | * @param file a java.io.File object for the filename that the selector↵
|
26 | * can use↵ | | 26 | * can use↵
|
27 | * @return whether the file should be selected or not↵ | | 27 | * @return whether the file should be selected or not↵
|
28 | */↵ | | 28 | */↵
|
29 | public boolean isSelected(File basedir, String filename, File file) {↵ | | 29 | public boolean isSelected(File basedir, String filename, File file) {↵
|
30 | validate();↵ | | 30 | validate();↵
|
31 | Enumeration e = selectorElements();↵ | | 31 | Enumeration e = selectorElements();↵
|
32 | boolean result;↵ | | 32 | boolean result;↵
|
|
| | | 33 | // First, check that all elements are correctly configured↵
|
33 | while (e.hasMoreElements()) {↵ | | 34 | while (e.hasMoreElements()) {↵
|
34 | result = ((FileSelector) e.nextElement()).isSelected(basedir,↵ | | 35 | result = ((FileSelector) e.nextElement()).isSelected(basedir,↵
|
35 | filename, file);↵ | | 36 | filename, file);↵
|
36 | if (result) {↵ | | 37 | if (result) {↵
|
37 | return false;↵ | | 38 | return true;↵
|
38 | }↵ | | 39 | }↵
|
39 | }↵ | | 40 | }↵
|
40 | return true;↵ | | 41 | return false;↵
|
41 | } | | 42 | }
|