java.lang.Object
org.klomp.snark.bencode.BEncoder.StringKeyComparator
All Implemented Interfaces:
Serializable, Comparator<String>
Enclosing class:
BEncoder

private static class BEncoder.StringKeyComparatorextends Object implements Comparator<String>, Serializable
Compares bencode map keys given as Strings, in the order the spec requires: as their UTF-8 encodings, byte by byte, with a shorter key that is a prefix of a longer one ordered first.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Pinned for serialized-form compatibility.
      See Also:
  • Constructor Details

    • StringKeyComparator

      private StringKeyComparator()
      Orders bencode keys so the output is stable.
  • Method Details

    • compare

      public int compare(String l, String r)
      Compares two keys by their UTF-8 encodings.
      Specified by:
      compare in interface Comparator<String>
      Parameters:
      l - the first key
      r - the second key
      Returns:
      negative if l is less, positive if greater, 0 if equal