Package adams.core.io.dirchanged
Class AbstractDirChangeMonitor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.io.dirchanged.AbstractDirChangeMonitor
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,DirChangeMonitor,LoggingLevelHandler,LoggingSupporter,OptionHandler,QuickInfoSupporter,SizeOfHandler,Serializable
- Direct Known Subclasses:
AbstractMessageDigestBasedMonitor,LastModified,MultiMonitor,NoChange,Size
public abstract class AbstractDirChangeMonitor extends AbstractOptionHandler implements DirChangeMonitor, QuickInfoSupporter
Ancestor for dir change monitors.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Filem_Dirthe dir to monitor.protected booleanm_Initializedwhether the monitor has been initialized.protected Set<File>m_LastFilesthe list of files from the last check.protected BaseRegExpm_RegExpthe regexp for the files to list.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractDirChangeMonitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract booleancheckChange(File dir)Performs the actual check whether the dir has changed.protected booleancheckContentChanged(File dir)Fast check whether the number of files or names have changed.protected StringcheckFile(File dir)Performs some basic checks on the dir.voiddefineOptions()Adds options to the internal list of options.protected abstract StringdoInitialize(File dir)Performs the actual initialization of the monitor with the specified dir.protected abstract StringdoUpdate(File dir)Performs the actual updating of the monitor with the specified dir.FilegetMonitoredDir()Returns the dir that is being monitored.StringgetQuickInfo()Returns a quick info about the object, which can be displayed in the GUI.BaseRegExpgetRegExp()Returns the regular expression for selecting a subset of files to monitor.booleanhasChanged(File dir)Checks whether the dir has changed.Stringinitialize(File dir)Initializes the monitor with the specified file.booleanisInitialized(File dir)Checks whether the monitor has been initialized with the specified dir.protected List<File>listFiles(File dir)Returns a list of files in the specified directory.StringregExpTipText()Returns the tip text for this property.protected voidreset()Resets the scheme.voidsetRegExp(BaseRegExp value)Sets the regular expression for selecting the subset of files to monitor in the directory.Stringupdate(File dir)Updates the monitor with the specified dir.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_RegExp
protected BaseRegExp m_RegExp
the regexp for the files to list.
-
m_Initialized
protected boolean m_Initialized
whether the monitor has been initialized.
-
m_Dir
protected File m_Dir
the dir to monitor.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classAbstractOptionHandler
-
setRegExp
public void setRegExp(BaseRegExp value)
Sets the regular expression for selecting the subset of files to monitor in the directory.- Parameters:
value- the regexp
-
getRegExp
public BaseRegExp getRegExp()
Returns the regular expression for selecting a subset of files to monitor.- Returns:
- the regexp
-
regExpTipText
public String regExpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.- Specified by:
getQuickInfoin interfaceQuickInfoSupporter- Returns:
- null if no info available, otherwise short string
-
isInitialized
public boolean isInitialized(File dir)
Checks whether the monitor has been initialized with the specified dir.- Specified by:
isInitializedin interfaceDirChangeMonitor- Parameters:
dir- the dir to check- Returns:
- true if setup for this dir
- See Also:
initialize(File)
-
checkFile
protected String checkFile(File dir)
Performs some basic checks on the dir.- Parameters:
dir- the dir to check- Returns:
- null if successful, otherwise error message
-
doInitialize
protected abstract String doInitialize(File dir)
Performs the actual initialization of the monitor with the specified dir.- Parameters:
dir- the dir to initialize with- Returns:
- null if successful, otherwise error message
-
initialize
public String initialize(File dir)
Initializes the monitor with the specified file.- Specified by:
initializein interfaceDirChangeMonitor- Parameters:
dir- the dir to initialize with- Returns:
- null if successful, otherwise error message
-
getMonitoredDir
public File getMonitoredDir()
Returns the dir that is being monitored.- Specified by:
getMonitoredDirin interfaceDirChangeMonitor- Returns:
- the dir, null if not initialized
-
listFiles
protected List<File> listFiles(File dir)
Returns a list of files in the specified directory.- Parameters:
dir- the directory to get the files for- Returns:
- the list of files
-
checkContentChanged
protected boolean checkContentChanged(File dir)
Fast check whether the number of files or names have changed.- Parameters:
dir- the dir to check- Returns:
- true if changed
-
checkChange
protected abstract boolean checkChange(File dir)
Performs the actual check whether the dir has changed.- Parameters:
dir- the dir to check- Returns:
- true if changed
-
hasChanged
public boolean hasChanged(File dir)
Checks whether the dir has changed. Must be initialized beforehand.- Specified by:
hasChangedin interfaceDirChangeMonitor- Parameters:
dir- the dir to check- Returns:
- true if changed
- See Also:
isInitialized(File),initialize(File)
-
doUpdate
protected abstract String doUpdate(File dir)
Performs the actual updating of the monitor with the specified dir.- Parameters:
dir- the dir to update with- Returns:
- null if successful, otherwise error message
-
update
public String update(File dir)
Updates the monitor with the specified dir.- Specified by:
updatein interfaceDirChangeMonitor- Parameters:
dir- the dir to update with- Returns:
- null if successful, otherwise error message
-
-