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 Filem_Filethe file to monitor.protected booleanm_Initializedwhether 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 booleancheckChange(File file)Performs the actual check whether the file has changed.protected StringcheckFile(File file)Performs some basic checks on the file.protected abstract StringdoInitialize(File file)Performs the actual initialization of the monitor with the specified file.protected abstract StringdoUpdate(File file)Performs the actual updating of the monitor with the specified file.FilegetMonitoredFile()Returns the file that is being monitored.StringgetQuickInfo()Returns a quick info about the object, which can be displayed in the GUI.booleanhasChanged(File file)Checks whether the file has changed.Stringinitialize(File file)Initializes the monitor with the specified file.booleanisInitialized(File file)Checks whether the monitor has been initialized with the specified file.protected voidreset()Resets the scheme.Stringupdate(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:
resetin 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:
getQuickInfoin 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:
isInitializedin 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:
initializein 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:
getMonitoredFilein 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:
hasChangedin 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:
updatein interfaceFileChangeMonitor- Parameters:
file- the file to update with- Returns:
- null if successful, otherwise error message
-
-