// handle missing config file
if (reader == null) {
if (LOG.isWarnEnabled()) {
LOG.warn("Missing urlfilter.suffix.file, all URLs will be rejected!");
}
suffixes = new SuffixStringMatcher(new String[0]);
modeAccept = false;
ignoreCase = false;
return;
}
BufferedReader in = new BufferedReader(reader);
List aSuffixes = new ArrayList();
boolean allow = false;
boolean ignore = false;
String line;
while ((line = in.readLine()) != null) {
if (line.length() == 0) continue;
char first = line.charAt(0);
switch (first) {
case ' ':
case '\n':
case '#': // skip blank & comment lines
break;
case '-':
allow = false;
if (line.length() > 1 && line.charAt(1) == 'I')
ignore = true;
break;
case '+':
allow = true;
if (line.length() > 1 && line.charAt(1) == 'I')
ignore = true;
break;
default:
aSuffixes.add(line);
}
}
if (ignore) {
for (int i = 0; i < aSuffixes.size(); i++) {
aSuffixes.set(i, ((String) aSuffixes.get(i)).toLowerCase());
}
}
suffixes = new SuffixStringMatcher(aSuffixes);
modeAccept = allow;
ignoreCase = ignore;
}