Class RegexFTPFileEntryParserImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.regex.Matcher _matcher_
      Internal PatternMatcher object used by the parser.
      private java.util.regex.Pattern pattern
      internal pattern the matcher tries to match, representing a file entry
      private java.util.regex.MatchResult result
      internal match result used by the parser
    • Constructor Summary

      Constructors 
      Constructor Description
      RegexFTPFileEntryParserImpl​(java.lang.String regex)
      The constructor for a RegexFTPFileEntryParserImpl object.
      RegexFTPFileEntryParserImpl​(java.lang.String regex, int flags)
      The constructor for a RegexFTPFileEntryParserImpl object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void compileRegex​(java.lang.String regex, int flags)
      Compile the regex and store the Pattern.
      int getGroupCnt()
      Convenience method
      java.lang.String getGroupsAsString()
      For debugging purposes - returns a string shows each match group by number.
      java.lang.String group​(int matchnum)
      Convenience method delegates to the internal MatchResult's group() method.
      boolean matches​(java.lang.String s)
      Convenience method delegates to the internal MatchResult's matches() method.
      boolean setRegex​(java.lang.String regex)
      Alter the current regular expression being utilised for entry parsing and create a new Pattern instance.
      boolean setRegex​(java.lang.String regex, int flags)
      Alter the current regular expression being utilised for entry parsing and create a new Pattern instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pattern

        private java.util.regex.Pattern pattern
        internal pattern the matcher tries to match, representing a file entry
      • result

        private java.util.regex.MatchResult result
        internal match result used by the parser
      • _matcher_

        protected java.util.regex.Matcher _matcher_
        Internal PatternMatcher object used by the parser. It has protected scope in case subclasses want to make use of it for their own purposes.
    • Constructor Detail

      • RegexFTPFileEntryParserImpl

        public RegexFTPFileEntryParserImpl​(java.lang.String regex)
        The constructor for a RegexFTPFileEntryParserImpl object. The expression is compiled with flags = 0.
        Parameters:
        regex - The regular expression with which this object is initialized.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the regular expression is unparseable. Should not be seen in normal conditions. It it is seen, this is a sign that a subclass has been created with a bad regular expression. Since the parser must be created before use, this means that any bad parser subclasses created from this will bomb very quickly, leading to easy detection.
      • RegexFTPFileEntryParserImpl

        public RegexFTPFileEntryParserImpl​(java.lang.String regex,
                                           int flags)
        The constructor for a RegexFTPFileEntryParserImpl object.
        Parameters:
        regex - The regular expression with which this object is initialized.
        flags - the flags to apply, see Pattern.compile(String, int). Use 0 for none.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the regular expression is unparseable. Should not be seen in normal conditions. It it is seen, this is a sign that a subclass has been created with a bad regular expression. Since the parser must be created before use, this means that any bad parser subclasses created from this will bomb very quickly, leading to easy detection.
        Since:
        3.4
    • Method Detail

      • compileRegex

        private void compileRegex​(java.lang.String regex,
                                  int flags)
        Compile the regex and store the Pattern. This is an internal method to do the work so the constructor does not have to call an overrideable method.
        Parameters:
        regex - the expression to compile
        flags - the flags to apply, see Pattern.compile(String, int). Use 0 for none.
        Throws:
        java.lang.IllegalArgumentException - if the regex cannot be compiled
      • getGroupCnt

        public int getGroupCnt()
        Convenience method
        Returns:
        the number of groups() in the internal MatchResult.
      • getGroupsAsString

        public java.lang.String getGroupsAsString()
        For debugging purposes - returns a string shows each match group by number.
        Returns:
        a string shows each match group by number.
      • group

        public java.lang.String group​(int matchnum)
        Convenience method delegates to the internal MatchResult's group() method.
        Parameters:
        matchnum - match group number to be retrieved
        Returns:
        the content of the matchnum'th group of the internal match or null if this method is called without a match having been made.
      • matches

        public boolean matches​(java.lang.String s)
        Convenience method delegates to the internal MatchResult's matches() method.
        Parameters:
        s - the String to be matched
        Returns:
        true if s matches this object's regular expression.
      • setRegex

        public boolean setRegex​(java.lang.String regex)
        Alter the current regular expression being utilised for entry parsing and create a new Pattern instance.
        Parameters:
        regex - The new regular expression
        Returns:
        true
        Throws:
        java.lang.IllegalArgumentException - if the regex cannot be compiled
        Since:
        2.0
      • setRegex

        public boolean setRegex​(java.lang.String regex,
                                int flags)
        Alter the current regular expression being utilised for entry parsing and create a new Pattern instance.
        Parameters:
        regex - The new regular expression
        flags - the flags to apply, see Pattern.compile(String, int). Use 0 for none.
        Returns:
        true
        Throws:
        java.lang.IllegalArgumentException - if the regex cannot be compiled
        Since:
        3.4