Class AbstractNotesReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.tools.previewbrowser.notes.AbstractNotesReader
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,FileFormatHandler,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Serializable
- Direct Known Subclasses:
CsvNotesReader,JsonNotesReader,PropertiesNotesReader,YamlNotesReader
public abstract class AbstractNotesReader extends AbstractOptionHandler implements FileFormatHandler
Ancestor for notes readers.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
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 AbstractNotesReader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddIfFileExists(Map<String,String> notes, PlaceholderDirectory dir, String file, String note)Adds the note if the file exists.protected Stringcheck(PlaceholderFile file)Hook method for checks before reading the notes.protected abstract Map<String,String>doRead(PlaceholderFile file, MessageCollection errors)Reads the notes from the specified file.abstract AbstractNotesWritergetCorrespondingWriter()Returns the corresponding writer.protected abstract StringgetDefaultFileName()Returns the default file name for the notes file.Map<String,String>read(PlaceholderDirectory dir, MessageCollection errors)Reads the notes from the specified directory.Map<String,String>read(PlaceholderFile file, MessageCollection errors)Reads the notes from the specified file.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, 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.io.FileFormatHandler
getDefaultFormatExtension, getFormatDescription, getFormatExtensions
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
getDefaultFileName
protected abstract String getDefaultFileName()
Returns the default file name for the notes file.- Returns:
- the name, no path
-
getCorrespondingWriter
public abstract AbstractNotesWriter getCorrespondingWriter()
Returns the corresponding writer.- Returns:
- the writer, null if not available
-
doRead
protected abstract Map<String,String> doRead(PlaceholderFile file, MessageCollection errors)
Reads the notes from the specified file.- Parameters:
file- the file to read the notes fromerrors- for recording errors- Returns:
- the notes, null if failed to read
-
check
protected String check(PlaceholderFile file)
Hook method for checks before reading the notes.- Parameters:
file- the file to store the notes in- Returns:
- null if checks passed, otherwise error message
-
addIfFileExists
protected void addIfFileExists(Map<String,String> notes, PlaceholderDirectory dir, String file, String note)
Adds the note if the file exists.- Parameters:
notes- the notes to updatedir- the directory the notes are forfile- the file that must existnote- the note for the file
-
read
public Map<String,String> read(PlaceholderDirectory dir, MessageCollection errors)
Reads the notes from the specified directory. Uses the default notes name.- Parameters:
dir- the directory to store the notes inerrors- for recording errors- Returns:
- the notes, null if failed to read
- See Also:
getDefaultFileName()
-
read
public Map<String,String> read(PlaceholderFile file, MessageCollection errors)
Reads the notes from the specified file.- Parameters:
file- the file to read the notes fromerrors- for recording errors- Returns:
- null if successfully written, otherwise error message
-
-