java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.StatHelper

public class StatHelperextends HelperBase
Helper for statistics page rendering and form processing.
  • Field Details

    • _peer

      private String _peer
      Peer whose stats are shown, if filtered.
    • _full

      private boolean _full
      True to show every stat, not just the summary.
    • _statFilter

      private String _statFilter
      Only stats containing this are shown.
    • _export

      private String _export
      Format asked for when exporting the stats.
  • Constructor Details

    • StatHelper

      public StatHelper()
      No peer selected, no filter, and no export format; the setters below fill those in from the form parameters before anything is rendered.
  • Method Details

    • setPeer

      public void setPeer(String peer)
      Caller should strip HTML (XSS).
      Parameters:
      peer - the base64 hash selecting a single peer to report on, or null to report on all peers
    • setFull

      public void setFull(String f)
      Set full flag for stats generation.
      Parameters:
      f - any non-empty value to generate the full stat set; null or empty leaves the flag off
    • setStatFilter

      public void setStatFilter(String filter)
      Optional stat name filter (substring match, case-insensitive). Only stats whose name contains this string will be rendered.
      Parameters:
      filter - the case-insensitive substring that stat names must contain to be rendered; null or empty clears the filter
    • setExport

      public void setExport(String export)
      Export format (csv or xml).
      Parameters:
      export - the requested format, accepted only as "csv" or "xml"; any other value leaves the export unset
    • getExportData

      public String getExportData()
      Export data as CSV or XML.
      Returns:
      the export data
    • getProfile

      public String getProfile()
      Retrieve peer profile or stats based on usage.
      Returns:
      the HTML for the requested peer's profile: the "No peer specified" notice if none was given, the full profile for a complete destination hash, the first profile whose hash starts with the given prefix, or a "Peer profile unavailable" message
    • getStats

      public String getStats()
      Get stats page as string or write to output stream.
      Returns:
      the rendered stats page, or an empty string when an output stream was supplied and the page was written there instead; an error message if generation failed
    • outputProfile

      private String outputProfile()
      Look up based on the full b64 - efficient.
      Returns:
      the dumped profile, or an error message for a bad peer hash
    • dumpProfile

      private String dumpProfile(Hash peer)
      Dump the profile.
      Parameters:
      peer - the peer whose profile to dump
      Returns:
      empty string if the profile was written to the output, otherwise an error message