java.lang.Object
org.klomp.snark.web.Sorters

class Sortersextends Object
Comparators for various columns.
  • Field Details

    • PATTERN_DE

      private static final Pattern PATTERN_DE
      See below.
    • PATTERN_EN

      private static final Pattern PATTERN_EN
      Extracts the sort key from an English torrent name.
    • PATTERN_ES

      private static final Pattern PATTERN_ES
      Extracts the sort key from a Spanish torrent name.
    • PATTERN_FR

      private static final Pattern PATTERN_FR
      Extracts the sort key from a French torrent name.
    • PATTERN_IT

      private static final Pattern PATTERN_IT
      Extracts the sort key from an Italian torrent name.
    • PATTERN_NL

      private static final Pattern PATTERN_NL
      Extracts the sort key from a Dutch torrent name.
    • PATTERN_PT

      private static final Pattern PATTERN_PT
      Extracts the sort key from a Portuguese torrent name.
    • STATUS_MAGNET

      private static final int STATUS_MAGNET
      Sort rank for a magnet-only torrent.
      See Also:
    • STATUS_UNKNOWN

      private static final int STATUS_UNKNOWN
      Sort rank for an unknown state.
      See Also:
    • STATUS_ALLOCATION

      private static final int STATUS_ALLOCATION
      Sort rank while allocating space.
      See Also:
    • STATUS_CHECKING

      private static final int STATUS_CHECKING
      Sort rank while checking existing data.
      See Also:
    • STATUS_STARTING

      private static final int STATUS_STARTING
      Sort rank while starting up.
      See Also:
    • STATUS_DOWNLOADING

      private static final int STATUS_DOWNLOADING
      Sort rank while downloading.
      See Also:
    • STATUS_STALLED

      private static final int STATUS_STALLED
      Sort rank for a stalled download.
      See Also:
    • STATUS_NO_ACTIVE_PEERS

      private static final int STATUS_NO_ACTIVE_PEERS
      Sort rank with peers but none active.
      See Also:
    • STATUS_NO_PEERS

      private static final int STATUS_NO_PEERS
      Sort rank with no peers at all.
      See Also:
    • STATUS_SEEDING_ACTIVE

      private static final int STATUS_SEEDING_ACTIVE
      Sort rank while seeding with takers.
      See Also:
    • STATUS_SEEDING_INACTIVE

      private static final int STATUS_SEEDING_INACTIVE
      Sort rank while seeding with no takers.
      See Also:
    • STATUS_SEEDING_IDLE

      private static final int STATUS_SEEDING_IDLE
      Sort rank while seeding without activity.
      See Also:
    • STATUS_STOPPED_OFFSET

      private static final int STATUS_STOPPED_OFFSET
      Sort rank offset added for a stopped torrent.
      See Also:
  • Constructor Details

    • Sorters

      Sorters()
      The outer class only groups the comparators below and holds their static patterns, so an instance carries nothing.
  • Method Details

    • getComparator

      public static Comparator<Snark> getComparator(int type, String lang, I2PSnarkServlet servlet)
      Build the comparator that orders the torrent list by a details-page column.
      • 0, 1: Name
      • 2: Status
      • 3: Peers
      • 4: ETA
      • 5: Size
      • 6: Downloaded
      • 7: Uploaded
      • 8: Down rate
      • 9: Up rate
      • 10: Remaining (needed)
      • 11: Upload ratio
      • 12: File type
      • 13: Pool, then status
      Parameters:
      type - the column to sort by, negative to reverse the order, as listed in the tag table above
      lang - the locale used to collate torrent names
      servlet - for file type callback only
      Returns:
      a comparator implementing the requested column ordering, falling back to name ordering for an unlisted column
    • getCollator

      private static Collator getCollator(String lang)
      The collator for the language, case-insensitive at secondary strength (accents distinct, case not), the default locale when null.
      Parameters:
      lang - may be null
      Returns:
      a collator for that locale, or for the default locale when lang is null
    • getFileComparator

      public static Comparator<Sorters.FileAndIndex> getFileComparator(int type, I2PSnarkServlet servlet)
      Build the comparator that orders a torrent's file entries by a details-page column.
      • 0, 1: Name
      • 5: Size
      • 10: Remaining (needed)
      • 12: File type
      • 13: Priority
      Parameters:
      type - the column to sort by, negative to reverse the order, as listed in the tag table above
      servlet - for file type callback only
      Returns:
      a comparator implementing the requested column ordering, falling back to name ordering for an unlisted column
    • getPattern

      private static Pattern getPattern(String lang)
      The translated value, null for none.
      Parameters:
      lang - null for none
      Returns:
      null for none