Package adams.core.io.filechanged
Class AbstractFileChangeMonitor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.io.filechanged.AbstractFileChangeMonitor
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,FileChangeMonitor
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,Serializable
- Direct Known Subclasses:
AbstractMessageDigestBasedMonitor
,LastModified
,MultiMonitor
,NoChange
,Size
public abstract class AbstractFileChangeMonitor extends AbstractOptionHandler implements FileChangeMonitor, QuickInfoSupporter
Ancestor for file change monitors.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected File
m_File
the file to monitor.protected boolean
m_Initialized
whether the monitor has been initialized.-
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 AbstractFileChangeMonitor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
checkChange(File file)
Performs the actual check whether the file has changed.protected String
checkFile(File file)
Performs some basic checks on the file.protected abstract String
doInitialize(File file)
Performs the actual initialization of the monitor with the specified file.protected abstract String
doUpdate(File file)
Performs the actual updating of the monitor with the specified file.File
getMonitoredFile()
Returns the file that is being monitored.String
getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.boolean
hasChanged(File file)
Checks whether the file has changed.String
initialize(File file)
Initializes the monitor with the specified file.boolean
isInitialized(File file)
Checks whether the monitor has been initialized with the specified file.protected void
reset()
Resets the scheme.String
update(File file)
Updates the monitor with the specified file.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, 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_Initialized
protected boolean m_Initialized
whether the monitor has been initialized.
-
m_File
protected File m_File
the file to monitor.
-
-
Method Detail
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractOptionHandler
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.
Default implementation returns null.- Specified by:
getQuickInfo
in interfaceQuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
isInitialized
public boolean isInitialized(File file)
Checks whether the monitor has been initialized with the specified file.- Specified by:
isInitialized
in interfaceFileChangeMonitor
- Parameters:
file
- the file to check- Returns:
- true if setup for this file
- See Also:
initialize(File)
-
checkFile
protected String checkFile(File file)
Performs some basic checks on the file.- Parameters:
file
- the file to check- Returns:
- null if successful, otherwise error message
-
doInitialize
protected abstract String doInitialize(File file)
Performs the actual initialization of the monitor with the specified file.- Parameters:
file
- the file to initialize with- Returns:
- null if successful, otherwise error message
-
initialize
public String initialize(File file)
Initializes the monitor with the specified file.- Specified by:
initialize
in interfaceFileChangeMonitor
- Parameters:
file
- the file to initialize with- Returns:
- null if successful, otherwise error message
-
getMonitoredFile
public File getMonitoredFile()
Returns the file that is being monitored.- Specified by:
getMonitoredFile
in interfaceFileChangeMonitor
- Returns:
- the file, null if not initialized
-
checkChange
protected abstract boolean checkChange(File file)
Performs the actual check whether the file has changed.- Parameters:
file
- the file to check- Returns:
- true if changed
-
hasChanged
public boolean hasChanged(File file)
Checks whether the file has changed. Must be initialized beforehand.- Specified by:
hasChanged
in interfaceFileChangeMonitor
- Parameters:
file
- the file to check- Returns:
- true if changed
- See Also:
isInitialized(File)
,initialize(File)
-
doUpdate
protected abstract String doUpdate(File file)
Performs the actual updating of the monitor with the specified file.- Parameters:
file
- the file to update with- Returns:
- null if successful, otherwise error message
-
update
public String update(File file)
Updates the monitor with the specified file.- Specified by:
update
in interfaceFileChangeMonitor
- Parameters:
file
- the file to update with- Returns:
- null if successful, otherwise error message
-
-