java.lang.Object
org.klomp.snark.web.Sorters
Comparators for various columns.
Nested Class Summary
Modifier and TypeClassDescriptionprivate static classOrders torrents by bytes downloaded.private static classOrders torrents by download rate.private static classOrders torrents by estimated finish time.private static classOrders files by download priority.private static classOrders files by bytes left to download.private static classOrders files by size.private static classForward or reverse sort, but the fallback is always forward.private static classOrders files by type.static classClass to precompute and efficiently sort data on a torrent file entry.private static classSort alphabetically in current locale, ignore case, directories first.private static classOrders torrents by the type of their main file.private static classOrders torrents by peer count.private static classOrders torrents by upload-to-download ratio.private static classOrders torrents by bytes left to download.private static classOrders torrents by total size.private static classForward or reverse sort, but the fallback is always forward.private static classOrders torrents by their download state.private static classSort strictly by pool number, then by status; ties fall back to the status tie-breaks.private static classSort alphabetically in current locale, ignore case, ignore leading articles such as "the" if the pattern is set by setPattern().private static classOrders torrents by bytes uploaded.private static classOrders torrents by upload rate.Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final PatternSee below.private static final PatternExtracts the sort key from an English torrent name.private static final PatternExtracts the sort key from a Spanish torrent name.private static final PatternExtracts the sort key from a French torrent name.private static final PatternExtracts the sort key from an Italian torrent name.private static final PatternExtracts the sort key from a Dutch torrent name.private static final PatternExtracts the sort key from a Portuguese torrent name.private static final intSort rank while allocating space.private static final intSort rank while checking existing data.private static final intSort rank while downloading.private static final intSort rank for a magnet-only torrent.private static final intSort rank with peers but none active.private static final intSort rank with no peers at all.private static final intSort rank while seeding with takers.private static final intSort rank while seeding without activity.private static final intSort rank while seeding with no takers.private static final intSort rank for a stalled download.private static final intSort rank while starting up.private static final intSort rank offset added for a stopped torrent.private static final intSort rank for an unknown state.Constructor Summary
ConstructorsConstructorDescriptionSorters()The outer class only groups the comparators below and holds their static patterns, so an instance carries nothing.Method Summary
Modifier and TypeMethodDescriptionprivate static CollatorgetCollator(String lang) The collator for the language, case-insensitive at secondary strength (accents distinct, case not), the default locale when null.static Comparator<Snark> getComparator(int type, String lang, I2PSnarkServlet servlet) Build the comparator that orders the torrent list by a details-page column.static Comparator<Sorters.FileAndIndex> getFileComparator(int type, I2PSnarkServlet servlet) Build the comparator that orders a torrent's file entries by a details-page column.private static PatterngetPattern(String lang) The translated value, null for none.
Field Details
PATTERN_DE
See below.PATTERN_EN
Extracts the sort key from an English torrent name.PATTERN_ES
Extracts the sort key from a Spanish torrent name.PATTERN_FR
Extracts the sort key from a French torrent name.PATTERN_IT
Extracts the sort key from an Italian torrent name.PATTERN_NL
Extracts the sort key from a Dutch torrent name.PATTERN_PT
Extracts the sort key from a Portuguese torrent name.STATUS_MAGNET
private static final int STATUS_MAGNETSort rank for a magnet-only torrent.- See Also:
STATUS_UNKNOWN
private static final int STATUS_UNKNOWNSort rank for an unknown state.- See Also:
STATUS_ALLOCATION
private static final int STATUS_ALLOCATIONSort rank while allocating space.- See Also:
STATUS_CHECKING
private static final int STATUS_CHECKINGSort rank while checking existing data.- See Also:
STATUS_STARTING
STATUS_DOWNLOADING
private static final int STATUS_DOWNLOADINGSort rank while downloading.- See Also:
STATUS_STALLED
private static final int STATUS_STALLEDSort rank for a stalled download.- See Also:
STATUS_NO_ACTIVE_PEERS
private static final int STATUS_NO_ACTIVE_PEERSSort rank with peers but none active.- See Also:
STATUS_NO_PEERS
private static final int STATUS_NO_PEERSSort rank with no peers at all.- See Also:
STATUS_SEEDING_ACTIVE
private static final int STATUS_SEEDING_ACTIVESort rank while seeding with takers.- See Also:
STATUS_SEEDING_INACTIVE
private static final int STATUS_SEEDING_INACTIVESort rank while seeding with no takers.- See Also:
STATUS_SEEDING_IDLE
private static final int STATUS_SEEDING_IDLESort rank while seeding without activity.- See Also:
STATUS_STOPPED_OFFSET
private static final int STATUS_STOPPED_OFFSETSort 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
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 abovelang- the locale used to collate torrent namesservlet- for file type callback only- Returns:
- a comparator implementing the requested column ordering, falling back to name ordering for an unlisted column
getCollator
getFileComparator
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 aboveservlet- for file type callback only- Returns:
- a comparator implementing the requested column ordering, falling back to name ordering for an unlisted column
getPattern