java.lang.Object
net.i2p.router.web.helpers.CapabilitiesRenderer

class CapabilitiesRendererextends Object
Renders router capability strings as HTML links, identically for the NetDb and Sybil views.
  • Field Details

    • CAP_REPLACEMENTS

      static final Map<Character, String> CAP_REPLACEMENTS
      Link HTML for the capability letters used by both views.
    • SYBIL_REPLACEMENTS

      static final Map<Character, String> SYBIL_REPLACEMENTS
      CAP_REPLACEMENTS plus the letters only the Sybil view links.
    • TIER_LETTERS

      private static final char[] TIER_LETTERS
      Tier state letters applyTierState(String, char, char, boolean) is built for, indexed by tier.
    • SUFFIX_LETTERS

      private static final char[] SUFFIX_LETTERS
      Reachability suffix letters, indexed by suffix (0 is "no suffix").
    • TIER_CLASS_REPLACEMENTS

      private static final String[] TIER_CLASS_REPLACEMENTS
      class=tier rewritten to class="tier is<letter>", indexed by tier.
    • SUFFIXED_OPENERS

      private static final String[][] SUFFIXED_OPENERS
      Link openers rewritten to carry <suffix><tier>, indexed by suffix then tier.
    • SUFFIXED_TIER_OPENERS

      private static final String[][][] SUFFIXED_TIER_OPENERS
      Tier link openers rewritten to carry <suffix><tier>, indexed by suffix, then tier, then as interleaved {needle, replacement} pairs over TIER_LINK_LETTERS.
  • Constructor Details

    • CapabilitiesRenderer

      CapabilitiesRenderer()
      Constructor. The letter-to-HTML tables are static and built in the static initializer, so an instance carries no state of its own.
  • Method Details

    • linkify

      static String linkify(String caps, Map<Character, String> replacements)
      Replaces each capability letter with its link HTML, leaving unknown letters as-is.
      Parameters:
      caps - the raw capability string
      replacements - the letter to link HTML map
      Returns:
      the linkified capability string
    • tierIndex

      private static int tierIndex(char tier)
      Index of a tier letter in TIER_LETTERS.
      Parameters:
      tier - the tier letter, or 0 for none
      Returns:
      the index, or -1 for an unrecognized letter
    • suffixIndex

      private static int suffixIndex(char suffix)
      Index of a reachability suffix in SUFFIX_LETTERS.
      Parameters:
      suffix - the suffix letter, or 0 for none
      Returns:
      the index, or -1 for an unrecognized letter
    • applyTierState

      static String applyTierState(String caps, char tier, char suffix, boolean suffixAll)
      Applies the router tier state to linkified caps: removes the bare tier letter, marks the tier class, and appends the reachability suffix to the capability links. Every replacement string is pre-built in TIER_CLASS_REPLACEMENTS, SUFFIXED_OPENERS and SUFFIXED_TIER_OPENERS, keyed by the tier and suffix letters.
      Parameters:
      caps - the linkified capability string
      tier - the tier letter D, E, or G, or 0 for none
      suffix - the reachability letter R or U, or 0 for no suffix
      suffixAll - if true, suffix every capability link, otherwise only the tier links
      Returns:
      the processed capability string
    • applyTierStateUncached

      private static String applyTierStateUncached(String caps, char tier, char suffix, boolean suffixAll)
      Tier-state rewrite for letters outside the pre-built tables. Not reachable from the console, which only passes D, E or G with an optional R or U; kept so an unexpected letter degrades to the original behaviour rather than being dropped.
      Parameters:
      caps - the linkified capability string
      tier - the tier letter
      suffix - the reachability letter, or 0 for none
      suffixAll - if true, suffix every capability link
      Returns:
      the processed capability string
    • capTooltip

      static String capTooltip(RouterContext ctx)
      Tooltip suffix shared by all capability links.
      Parameters:
      ctx - the router context for translation
      Returns:
      the tooltip suffix