java.lang.Object
net.i2p.router.transport.PeerHTMLRenderer

public class PeerHTMLRendererextends Object
HTML rendering of peers (flag, capability bar, identity block) for the NetDb, PeerHelper, and tunnel pages.

Extracted from CommSystemFacadeImpl (2026-09-06) so the peer-render cluster, its RouterInfo/capacity caches, and its i18n state live apart from the facade core. The facade retains thin commSystem() delegators so the public API is unchanged; collaborators (country lookup, reverse-DNS) are injected rather than fetched through commSystem() round-trips.

Pure memory-independent decisions (bandwidth classification, visible-cap cleanup) are package-visible statics so they can be tested without a running router; see PeerHTMLRendererDecisionTest.

  • Constructor Details

  • Method Details

    • renderPeerHTML

      public String renderPeerHTML(Hash peer, boolean extended)
      Renders HTML for a peer with optional extended info. Uses cached RouterInfo, country info, and reverse lookup cache.
      Parameters:
      peer - the hash of the peer to render
      extended - Whether to show extended capabilities
      Returns:
      HTML snippet representing peer
    • renderPeerFlag

      public String renderPeerFlag(Hash peer)
      Render the HTML flag image for the given peer.
      Parameters:
      peer - the hash of the peer whose country and flag image are rendered
      Returns:
      an HTML span holding the flag image, titled with the country name and resolved host when those are known, else a placeholder
    • renderPeerCaps

      public String renderPeerCaps(Hash peer, boolean inline)
      Renders the peer's capability HTML block. Caches data and removes unnecessary repeated computation.
      Parameters:
      peer - the hash of the peer whose capabilities are being rendered
      inline - If true, render inline without table wrapper
      Returns:
      HTML snippet of peer capabilities
    • classifyCapacity

      static String classifyCapacity(String caps)
      Highest-priority bandwidth capability char present in the caps string, or "?" when none is advertised.

      Priority follows RouterInfo.BW_CAPABILITY_CHARS order, so a peer advertising both a high and a low class is classified at its high end. This is the decision the former getCapacityCached inline loop made; it is exposed so the offline PeerHTMLRendererDecisionTest can pin both the string and the null/empty handling without a router.

      Parameters:
      caps - capabilities string (never null in practice; null treated as none)
      Returns:
      single bandwidth-class char or "?"