java.lang.Object
org.klomp.snark.web.Sorters.Sort
All Implemented Interfaces:
Serializable, Comparator<Snark>
Direct Known Subclasses:
Sorters.DownloadedComparator, Sorters.DownRateComparator, Sorters.ETAComparator, Sorters.FileTypeComparator, Sorters.PeersComparator, Sorters.RatioComparator, Sorters.RemainingComparator, Sorters.SizeComparator, Sorters.StatusComparator, Sorters.StatusPoolComparator, Sorters.UploadedComparator, Sorters.UpRateComparator
Enclosing class:
Sorters

private abstract static class Sorters.Sortextends Object implements Comparator<Snark>, Serializable
Forward or reverse sort, but the fallback is always forward.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Fixed id, the comparator is never serialized across versions.
      See Also:
    • _rev

      private final boolean _rev
      True to reverse the order.
    • _p

      private final Pattern _p
      Pattern extracting the name's sort key.
    • _c

      private final Collator _c
      Collator ordering the names for the language.
  • Constructor Details

    • Sort

      public Sort(boolean rev, String lang)
      Creates a sorter for one direction and language.
      Parameters:
      rev - true to reverse the order
      lang - the language whose collation to use
  • Method Details

    • compare

      public int compare(Snark l, Snark r)
      Specified by:
      compare in interface Comparator<Snark>
    • compareIt

      protected abstract int compareIt(Snark l, Snark r)
      Compare two torrents on the subclass's column, falling back to name order.
      Parameters:
      l - the left-hand torrent to compare
      r - the right-hand torrent to compare
      Returns:
      negative, zero or positive as l sorts before, with or after r
    • compLong

      protected static int compLong(long l, long r)
      Compares two longs without overflow.
      Parameters:
      l - the first value
      r - the second value
      Returns:
      negative, zero or positive as l is less, equal or greater