Class 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 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.
    • Constructor Detail

      • LastLineMatches

        public LastLineMatches()
    • Method Detail

      • setEncoding

        public void setEncoding​(BaseCharset value)
        Sets the encoding to use.
        Specified by:
        setEncoding in interface EncodingSupporter
        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:
        getEncoding in interface EncodingSupporter
        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:
        encodingTipText in interface EncodingSupporter
        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:
        isInUse in class AbstractFileUseCheck
        Parameters:
        file - the file to check
        Returns:
        true if in use