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

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

    • _log

      private Log _log
      Logger for this class.
    • _graphs

      private final Set<String> _graphs
      Names of the stats that have graphs.
    • _stats

      private final List<String> _stats
      List of names of stats which are remaining, ordered by nested groups.
    • _currentStatName

      private String _currentStatName
      Name of the stat being shown.
    • _currentGraphName

      private String _currentGraphName
      Graph file name for the stat being shown.
    • _currentStatDescription

      private String _currentStatDescription
      Description shown for the stat being shown.
    • _currentGroup

      private String _currentGroup
      Group the stat being shown belongs to.
    • _currentIsFirstInGroup

      private boolean _currentIsFirstInGroup
      True if the current stat is the first in the group.
    • _currentIsGraphed

      private boolean _currentIsGraphed
      True if the stat being shown is currently graphed.
    • _currentCanBeGraphed

      private boolean _currentCanBeGraphed
      True if the stat being shown could be graphed.
  • Constructor Details

    • ConfigStatsHelper

      public ConfigStatsHelper()
      Construct a new ConfigStatsHelper.
  • Method Details

    • setContextId

      public void setContextId(String contextId)
      Configure this bean to query a particular router context.
      Overrides:
      setContextId in class HelperBase
      Parameters:
      contextId - beginning few characters of the routerHash, or null to pick the first one we come across.
    • hasMoreStats

      public boolean hasMoreStats()
      Move the cursor to the next known stat, returning true if a valid stat is available.
      Returns:
      true if a valid stat is available, otherwise false
    • groupRequired

      public boolean groupRequired()
      Is the current stat the first in the group?
      Returns:
      true if the current stat is the first in the group
    • getCurrentGroupName

      public String getCurrentGroupName()
      What group is the current stat in.
      Returns:
      the current group name
    • getCurrentStatName

      public String getCurrentStatName()
      Get the current stat name.
      Returns:
      the stat name as entered, or null
    • getCurrentStatLabel

      public String getCurrentStatLabel()
      Get the display label for the current stat.
      Returns:
      the label shown beside the checkbox
    • statLabel

      static String statLabel(String statName)
      The short name shown beside a stat's checkbox on the configstats page.

      An ordinary stat name is a dotted subsystem path such as tunnel.buildTimeout, and the subsystem is dropped because the section header already states it. A pool's rates are named for the tunnel instead: [harry.i2p] InBps. The first dot there sits inside the name, and cutting at it turned four different services into four identical "i2p] InBps" labels. A prefix carrying a bracket or a space is therefore a name rather than a subsystem, and is shown whole.

      Parameters:
      statName - the stat name, or null
      Returns:
      the display label, never null; null yields the empty string
    • abbreviate

      private static String abbreviate(String label)
      Shorten a stat name to what fits beside its checkbox.

      The rules are ordered rather than alphabetical: receive rewrites to RX, which the later RXBps rule expands again to ReceiveBps, so the chain may not be reordered. Every rule names a stat actually seen on the page. The dotted rules only ever see a name whose subsystem prefix was dropped, a pool name with a dot in it having been returned whole by statLabel(String).

      Parameters:
      label - a stat name, with any subsystem prefix already removed
      Returns:
      the abbreviated label, never null
    • getCurrentGraphName

      public String getCurrentGraphName()
      Get the current graph name.
      Returns:
      the graph name as entered, or null
    • getCurrentStatDescription

      public String getCurrentStatDescription()
      Get the description of the current stat.
      Returns:
      the current stat description
    • getCurrentIsGraphed

      public boolean getCurrentIsGraphed()
      Check whether the current stat is graphed.
      Returns:
      true if the current stat is graphed
    • getCurrentCanBeGraphed

      public boolean getCurrentCanBeGraphed()
      Check whether the current stat can be graphed.
      Returns:
      true if the current stat can be graphed
    • getIsFull

      public boolean getIsFull()
      Check whether the full stats are enabled.
      Returns:
      true if full stats are enabled