java.lang.Object
net.i2p.router.sybil.Points
All Implemented Interfaces:
Comparable<Points>

public class Pointsextends Object implements Comparable<Points>
A total score and a List of reason Strings.
  • Field Details

    • points

      private double points
      The peer's standing, lower is more suspicious.
    • reasons

      private final List<String> reasons
      Why the points are what they are.
    • TWO_DECIMALS

      private static final DecimalFormat TWO_DECIMALS
      Format used when writing the points out.
  • Constructor Details

    • Points

      private Points()
      Create a new empty Points instance.
    • Points

      public Points(double d, String reason)
      Create a new Points instance with an initial value.
      Parameters:
      d - the point value to start from, positive for a penalty or negative for credit
      reason - may not contain '%'
  • Method Details

    • getPoints

      public double getPoints()
      Total points accumulated.
      Returns:
      the accumulated score, positive for penalties and negative for credits
    • getReasons

      public List<String> getReasons()
      Reasons accumulated with the points.
      Returns:
      the live list of accumulated reason strings, each one the signed amount formatted to two decimals, a colon, and the reason text
    • addPoints

      public void addPoints(double d, String reason)
      Add points with a reason.
      Parameters:
      d - the point value to add, positive for a penalty or negative for credit
      reason - may not contain '%'
    • compareTo

      public int compareTo(Points r)
      Specified by:
      compareTo in interface Comparable<Points>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Return a string representation.
      Overrides:
      toString in class Object
    • toString

      public void toString(StringBuilder buf)
      For persistence. Total points and reasons, '%' separated, no newline. The separation character is chosen to not conflict with decimal point in various locales, or chars in reasons, including HTML links, or special chars in Pattern.
      Parameters:
      buf - the buffer to append the total and the '%'-separated reasons to
    • fromString

      public static Points fromString(String s)
      For persistence.
      Parameters:
      s - the '%'-separated persistence string: the point total, then one entry per reason
      Returns:
      null on failure