|
From: <de...@us...> - 2003-10-10 08:09:39
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner
In directory sc8-pr-cvs1:/tmp/cvs-serv18710/babeldoc/modules/scanner/src/com/babeldoc/scanner
Modified Files:
ScannerWorker.java
Log Message:
Applied David Kinnvalls patch:
- Added missing messages to messages.properties
- Moved the patterns Hashtable to the top of the ScannerWorker
file and added a brief javadoc about it
- Re-ordered the methods and accompanying javadocs that got a
bit mixed up (addFilter and acceptEntry) and added a bit more
javadoc text explaining how the filter logic works
- Really "new" in this patch is only my previously suggested
addition of providing the DirectoryScanner's doneDirectory
under the attribute "done_dir"
Index: ScannerWorker.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/ScannerWorker.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** ScannerWorker.java 9 Oct 2003 06:54:10 -0000 1.28
--- ScannerWorker.java 10 Oct 2003 08:09:35 -0000 1.29
***************
*** 119,122 ****
--- 119,125 ----
private boolean binary;
+ /** Used to filter what documents to accept for processing */
+ private Hashtable patterns = new Hashtable();
+
public static final String SCANNER_KEY = "scanner";
public static final String SCAN_DATE_KEY = "scan_date";
***************
*** 218,230 ****
}
/**
! * Does this worker accept this entry
! *
! * @param filter filter string
! * @param string name to be filtered
! *
! * @return true if accepted - false otherwise
*/
- private Hashtable patterns = new Hashtable();
protected void addFilter(String filterName) {
String patternExp = (String) this.getInfo().getOption(filterName).getValue();
--- 221,241 ----
}
+
/**
! * Add named filter to use when deciding what documents
! * to accept for processing. This method gets called by
! * implementing subclasses to add filters specific to
! * each scanner implementation.
! *
! * The filter is fetched from the scanner configuration
! * and must be a valid Java regular expression according
! * to the documentation for java.util.regex.Pattern
! *
! * An empty or non-existing pattern is interpreted and
! * stored as ".*", i.e the match-all wildcard pattern.
! *
! * @param filterName Name of configured filter to add,
! * replaces any existing pattern having the same name
*/
protected void addFilter(String filterName) {
String patternExp = (String) this.getInfo().getOption(filterName).getValue();
***************
*** 239,246 ****
patternExp,
filterName));
! }
patterns.put(filterName, pattern);
}
protected boolean acceptEntry(String patternName, String text) {
Pattern pattern = (Pattern) patterns.get(patternName);
--- 250,270 ----
patternExp,
filterName));
! }
patterns.put(filterName, pattern);
}
+
+ /**
+ * Does this worker accept this entry when matched against
+ * the named pattern? If the pattern name does not exist,
+ * the entry is not accepted, else the entry is accepted
+ * if the entry matches the regular expression defined by
+ * the named pattern.
+ *
+ * @param patternName Name of pattern to use when matching
+ * @param text Text to match against the pattern
+ *
+ * @return true if accepted - false otherwise
+ */
protected boolean acceptEntry(String patternName, String text) {
Pattern pattern = (Pattern) patterns.get(patternName);
***************
*** 248,252 ****
LogService.getInstance().logDebug(
I18n.get("scanner.ScannerWorker.warn.noFilter", patternName));
! return false;
}
Matcher matcher = pattern.matcher(text);
--- 272,276 ----
LogService.getInstance().logDebug(
I18n.get("scanner.ScannerWorker.warn.noFilter", patternName));
! return false;
}
Matcher matcher = pattern.matcher(text);
***************
*** 303,307 ****
if (getLog().isDebugEnabled()) {
! getLog().logDebug(this.getName() + " worker initalized successfully");
}
--- 327,331 ----
if (getLog().isDebugEnabled()) {
! getLog().logDebug(this.getName() + " worker initialized successfully");
}
|