Package adams.core.io.fileuse
Class LastLineMatches
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.core.io.fileuse.AbstractFileUseCheck
-
- adams.core.io.fileuse.LastLineMatches
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,EncodingSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Serializable
public class LastLineMatches extends AbstractFileUseCheck implements EncodingSupporter
Reads the file as text file and makes sure that the last line matches the regular expression.
If the last line doesn't match the expression, failing to read or reading no lines at all are all interpreted as 'in use'.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-encoding <adams.core.base.BaseCharset> (property: encoding) The type of encoding to use when creating the string. default: Default
-regexp <adams.core.base.BaseRegExp> (property: regExp) The regular expression the last line must match. default: .* more: https://docs.oracle.com/javase/tutorial/essential/regex/ https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
-discard-empty-lines <boolean> (property: discardEmptyLines) If enabled, empty lines get discarded first before checking the last line. default: false
-trim <boolean> (property: trim) If enabled, lines get trimmed before checking for emptiness. default: false
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_DiscardEmptyLineswhether to discard empty lines.protected BaseCharsetm_Encodingthe encoding to use.protected BaseRegExpm_RegExpthe regular expression the last line must match.protected booleanm_Trimwhether to timr lines before checking emptiness.-
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 LastLineMatches()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddefineOptions()Adds options to the internal list of options.StringdiscardEmptyLinesTipText()Returns the tip text for this property.StringencodingTipText()Returns the tip text for this property.booleangetDiscardEmptyLines()Returns whether to discard empty lines.BaseCharsetgetEncoding()Returns the encoding to use.BaseRegExpgetRegExp()Returns the regular expression the last line must match.booleangetTrim()Returns whether to trim the lines first before checking emptiness.StringglobalInfo()Returns a string describing the object.booleanisInUse(File file)Checks whether the file is in use.StringregExpTipText()Returns the tip text for this property.voidsetDiscardEmptyLines(boolean value)Sets whether to discard empty lines.voidsetEncoding(BaseCharset value)Sets the encoding to use.voidsetRegExp(BaseRegExp value)Sets the regular expression the last line must match.voidsetTrim(boolean value)Sets whether to trim the lines first before checking emptiness.StringtrimTipText()Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, 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.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Encoding
protected BaseCharset m_Encoding
the encoding to use.
-
m_RegExp
protected BaseRegExp m_RegExp
the regular expression the last line must match.
-
m_DiscardEmptyLines
protected boolean m_DiscardEmptyLines
whether to discard empty lines.
-
m_Trim
protected boolean m_Trim
whether to timr lines before checking emptiness.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
setEncoding
public void setEncoding(BaseCharset value)
Sets the encoding to use.- Specified by:
setEncodingin interfaceEncodingSupporter- Parameters:
value- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
getEncoding
public BaseCharset getEncoding()
Returns the encoding to use.- Specified by:
getEncodingin interfaceEncodingSupporter- Returns:
- the encoding, e.g. "UTF-8" or "UTF-16", empty string for default
-
encodingTipText
public String encodingTipText()
Returns the tip text for this property.- Specified by:
encodingTipTextin interfaceEncodingSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRegExp
public void setRegExp(BaseRegExp value)
Sets the regular expression the last line must match.- Parameters:
value- the expression
-
getRegExp
public BaseRegExp getRegExp()
Returns the regular expression the last line must match.- Returns:
- the expression
-
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.
-
setDiscardEmptyLines
public void setDiscardEmptyLines(boolean value)
Sets whether to discard empty lines.- Parameters:
value- true if to discard
-
getDiscardEmptyLines
public boolean getDiscardEmptyLines()
Returns whether to discard empty lines.- Returns:
- true if to discard
-
discardEmptyLinesTipText
public String discardEmptyLinesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setTrim
public void setTrim(boolean value)
Sets whether to trim the lines first before checking emptiness.- Parameters:
value- true if to trim
-
getTrim
public boolean getTrim()
Returns whether to trim the lines first before checking emptiness.- Returns:
- true if to trim
-
trimTipText
public String trimTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
isInUse
public boolean isInUse(File file)
Checks whether the file is in use.- Specified by:
isInUsein classAbstractFileUseCheck- Parameters:
file- the file to check- Returns:
- true if in use
-
-