|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| FileStateMonitorFactory.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 | /* | |
| 2 | * $Id: FileStateMonitorFactory.java,v 1.1 2004/03/09 22:29:32 johndavidtaylor | |
| 3 | * Exp $ Created on Mar 9, 2004 by jdt The alipes project (c) 2004 | |
| 4 | * | |
| 5 | */ | |
| 6 | package org.abraracourcix.alipes.monitors.file; | |
| 7 | import java.io.File; | |
| 8 | import org.abraracourcix.alipes.common.RegExpFileFilter; | |
| 9 | import org.abraracourcix.alipes.listeners.Listener; | |
| 10 | /** | |
| 11 | * Simplifies the creation of FileStateMonitors if you have wildcards | |
| 12 | * @author jdt | |
| 13 | * | |
| 14 | */ | |
| 15 | public final class FileStateMonitorFactory { | |
| 16 | /** | |
| 17 | * Hide Constructor | |
| 18 | * | |
| 19 | */ | |
| 20 | 0 | private FileStateMonitorFactory() { |
| 21 | } | |
| 22 | /** | |
| 23 | * Construct and return a FileStateMonitor | |
| 24 | * | |
| 25 | * @param root | |
| 26 | * folder where the files are | |
| 27 | * @param pattern | |
| 28 | * regexp pattters to match | |
| 29 | * @param listener | |
| 30 | * who's listening | |
| 31 | * @param polling | |
| 32 | * polling interval in secs | |
| 33 | * @return said FileStateMonitor | |
| 34 | */ | |
| 35 | 0 | public static FileStateMonitor getFileStateMonitor( |
| 36 | final File root, | |
| 37 | final String pattern, | |
| 38 | final Listener listener, | |
| 39 | final int polling) { | |
| 40 | 0 | final FileStateMonitor monitor = |
| 41 | new FileStateMonitor(listener, polling); | |
| 42 | 0 | if (!(root.isDirectory())) { |
| 43 | 0 | throw new IllegalArgumentException("root must be a directory"); |
| 44 | } | |
| 45 | 0 | final File[] files = |
| 46 | root.listFiles(new RegExpFileFilter(pattern, root)); | |
| 47 | 0 | if (files != null) { |
| 48 | 0 | monitor.addFiles(files); |
| 49 | } | |
| 50 | 0 | return monitor; |
| 51 | } | |
| 52 | } | |
| 53 | /* | |
| 54 | * $Log: FileStateMonitorFactory.java,v $ | |
| 55 | * Revision 1.1 2004/03/17 21:18:02 johndavidtaylor | |
| 56 | * Copied across from incubation in beanpeeler | |
| 57 | * | |
| 58 | * Revision 1.4 2004/03/14 18:49:14 johndavidtaylor | |
| 59 | * corrected comments | |
| 60 | * | |
| 61 | * Revision 1.3 2004/03/11 15:46:33 johndavidtaylor | |
| 62 | * Applied coding standards | |
| 63 | * Revision 1.2 2004/03/11 09:49:23 | |
| 64 | * johndavidtaylor Loads of updates Revision 1.1 2004/03/09 22:29:32 | |
| 65 | * johndavidtaylor Added stuff for file wildcards/regexps | |
| 66 | * | |
| 67 | */ |
|
||||||||||