Class TorrentFilter


  • public class TorrentFilter
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern rangePattern  
    • Constructor Summary

      Constructors 
      Constructor Description
      TorrentFilter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List getTorrents​(java.util.List torrentsToMatch, java.lang.String filter)
      tries our two different matching algorithms using the supplied filter against the list of torrents in the ConsoleInput object
      java.util.List getTorrents​(java.util.List torrentsToMatch, java.util.List args)
      first tries to match torrents by concatenating all of the arguments.
      private java.util.List matchRange​(java.util.List torrents, java.lang.String filter)
      matches a range of torrents.
      private java.util.List matchWildcard​(java.util.List torrents, java.lang.String filter)
      attempst to match a wildcard against the list of torrents by checking their display name
      private java.lang.String wildcardToPattern​(java.lang.String wild)
      converts the wildcard (eg: tran*) into a regular expression - (tran.*)
      • Methods inherited from class java.lang.Object

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

      • rangePattern

        private static final java.util.regex.Pattern rangePattern
    • Constructor Detail

      • TorrentFilter

        public TorrentFilter()
    • Method Detail

      • matchRange

        private java.util.List matchRange​(java.util.List torrents,
                                          java.lang.String filter)
        matches a range of torrents. eg: 3-5 or a single torrent. eg: 3. or from 3 onwards: 3-
        Parameters:
        torrents - torrents to match
        filter - range expression
        Returns:
        list of matched DownloadManager objects
      • matchWildcard

        private java.util.List matchWildcard​(java.util.List torrents,
                                             java.lang.String filter)
        attempst to match a wildcard against the list of torrents by checking their display name
        Parameters:
        torrents - list of available torrents to match
        filter - wildcard (glob) filter
        Returns:
        list of matched DownloadManager objects
      • wildcardToPattern

        private java.lang.String wildcardToPattern​(java.lang.String wild)
        converts the wildcard (eg: tran*) into a regular expression - (tran.*)
        Parameters:
        wild - wildcard (glob) expression
        Returns:
        regular expression string
      • getTorrents

        public java.util.List getTorrents​(java.util.List torrentsToMatch,
                                          java.lang.String filter)
        tries our two different matching algorithms using the supplied filter against the list of torrents in the ConsoleInput object
        Parameters:
        torrentsToMatch - list of DownloadManager objects to attempt to match against
        filter - filter - eg: range or glob filter
        Returns:
        list of matched DownloadManager objects
      • getTorrents

        public java.util.List getTorrents​(java.util.List torrentsToMatch,
                                          java.util.List args)
        first tries to match torrents by concatenating all of the arguments. if that doesn't work, attempts to match each argument individually.
        Parameters:
        torrentsToMatch - list of DownloadManager objects to attempt to match against
        args - arguments to try to match
        Returns:
        list of matched DownloadManager objects