Skip to content

Commit ab2275f

Browse files
committed
Filter subclasses override Match() instead of creating Ignore()
1 parent 30bbb48 commit ab2275f

File tree

4 files changed

+20
-32
lines changed

4 files changed

+20
-32
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/index/Filter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class Filter implements Serializable {
4646
* The full list of all patterns. This list will be saved in the
4747
* configuration file (if used).
4848
*/
49-
private final List<String> items;
49+
private final PatternList items;
5050

5151
public Filter() {
5252
filenames = new HashSet<>();
@@ -154,7 +154,7 @@ public boolean match(File file) {
154154
* @return true if this pathname matches, false otherwise
155155
*/
156156
public boolean match(String name) {
157-
/**
157+
/*
158158
* Creating File object out of relative path would mean the path would be
159159
* checked against current working directory which is usually undesired.
160160
*/

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IgnoredDirs.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2019, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opengrok.indexer.index;
2425

@@ -45,21 +46,14 @@ public IgnoredDirs() {
4546
}
4647

4748
/**
48-
* Should the file be ignored or not?
49-
* @param file the file to check
50-
* @return true if this file should be ignored, false otherwise
49+
* Should the file (that must be a directory) be ignored or not?
50+
* @return {@code true} if {@code file} has
51+
* {@link File#isDirectory()} () == true} and should be ignored per
52+
* filtering
5153
*/
52-
public boolean ignore(File file) {
53-
return file.isDirectory() && match(file);
54-
}
55-
56-
/**
57-
* Should the file be ignored or not?
58-
* @param name the name of the file to check
59-
* @return true if this pathname should be ignored, false otherwise
60-
*/
61-
public boolean ignore(String name) {
62-
return match(name);
54+
@Override
55+
public boolean match(File file) {
56+
return file.isDirectory() && super.match(file);
6357
}
6458

6559
private void addDefaultPatterns() {

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IgnoredFiles.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2019, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opengrok.indexer.index;
2425

@@ -67,20 +68,12 @@ public IgnoredFiles() {
6768

6869
/**
6970
* Should the file be ignored or not?
70-
* @param file the file to check
71-
* @return true if this file should be ignored, false otherwise
71+
* @return {@code true} if {@code file} has {@link File#isFile() == true}
72+
* and should be ignored per filtering
7273
*/
73-
public boolean ignore(File file) {
74-
return file.isFile() && match(file);
75-
}
76-
77-
/**
78-
* Should the file be ignored or not?
79-
* @param name the name of the file to check
80-
* @return true if this pathname should be ignored, false otherwise
81-
*/
82-
public boolean ignore(String name) {
83-
return match(name);
74+
@Override
75+
public boolean match(File file) {
76+
return file.isFile() && super.match(file);
8477
}
8578

8679
private void addDefaultPatterns() {

opengrok-indexer/src/main/java/org/opengrok/indexer/index/IgnoredNames.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
22+
* Portions Copyright (c) 2019, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opengrok.indexer.index;
2425

@@ -76,9 +77,9 @@ public void add(String pattern) {
7677
*/
7778
public boolean ignore(File file) {
7879
if (file.isFile()) {
79-
return ignoredFiles.ignore(file);
80+
return ignoredFiles.match(file);
8081
} else {
81-
return ignoredDirs.ignore(file);
82+
return ignoredDirs.match(file);
8283
}
8384
}
8485

@@ -89,7 +90,7 @@ public boolean ignore(File file) {
8990
* @return true if this pathname should be ignored, false otherwise
9091
*/
9192
public boolean ignore(String name) {
92-
return ignoredFiles.ignore(name) || ignoredDirs.ignore(name);
93+
return ignoredFiles.match(name) || ignoredDirs.match(name);
9394
}
9495

9596
public void clear() {

0 commit comments

Comments
 (0)