java.lang.Object
net.i2p.router.web.helpers.CapabilitiesRenderer
Renders router capability strings as HTML links, identically for the NetDb and Sybil views.
Field Summary
FieldsModifier and TypeFieldDescriptionLink HTML for the capability letters used by both views.private static final char[]Reachability suffix letters, indexed by suffix (0 is "no suffix").private static final String[][]Link openers rewritten to carry<suffix><tier>, indexed by suffix then tier.private static final String[][][]Tier link openers rewritten to carry<suffix><tier>, indexed by suffix, then tier, then as interleaved {needle, replacement} pairs overTIER_LINK_LETTERS.CAP_REPLACEMENTS plus the letters only the Sybil view links.private static final String[]class=tierrewritten toclass="tier is<letter>", indexed by tier.private static final char[]Tier state lettersapplyTierState(String, char, char, boolean)is built for, indexed by tier.(package private) static final char[]Tier link letters, in the order they are suffixed.Constructor Summary
ConstructorsMethod Summary
Private MethodsModifier and TypeMethodDescription(package private) static StringapplyTierState(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.private static StringapplyTierStateUncached(String caps, char tier, char suffix, boolean suffixAll) Tier-state rewrite for letters outside the pre-built tables.(package private) static StringcapTooltip(RouterContext ctx) Tooltip suffix shared by all capability links.(package private) static StringReplaces each capability letter with its link HTML, leaving unknown letters as-is.private static intsuffixIndex(char suffix) Index of a reachability suffix inSUFFIX_LETTERS.private static inttierIndex(char tier) Index of a tier letter inTIER_LETTERS.
Field Details
CAP_REPLACEMENTS
SYBIL_REPLACEMENTS
TIER_LINK_LETTERS
static final char[] TIER_LINK_LETTERSTier link letters, in the order they are suffixed.TIER_LETTERS
private static final char[] TIER_LETTERSTier state lettersapplyTierState(String, char, char, boolean)is built for, indexed by tier.SUFFIX_LETTERS
private static final char[] SUFFIX_LETTERSReachability suffix letters, indexed by suffix (0 is "no suffix").TIER_CLASS_REPLACEMENTS
class=tierrewritten toclass="tier is<letter>", indexed by tier.SUFFIXED_OPENERS
Link openers rewritten to carry<suffix><tier>, indexed by suffix then tier.SUFFIXED_TIER_OPENERS
Tier link openers rewritten to carry<suffix><tier>, indexed by suffix, then tier, then as interleaved {needle, replacement} pairs overTIER_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
tierIndex
private static int tierIndex(char tier) Index of a tier letter inTIER_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 inSUFFIX_LETTERS.- Parameters:
suffix- the suffix letter, or 0 for none- Returns:
- the index, or -1 for an unrecognized letter
applyTierState
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 inTIER_CLASS_REPLACEMENTS,SUFFIXED_OPENERSandSUFFIXED_TIER_OPENERS, keyed by the tier and suffix letters.- Parameters:
caps- the linkified capability stringtier- the tier letter D, E, or G, or 0 for nonesuffix- the reachability letter R or U, or 0 for no suffixsuffixAll- 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 stringtier- the tier lettersuffix- the reachability letter, or 0 for nonesuffixAll- if true, suffix every capability link- Returns:
- the processed capability string
capTooltip
Tooltip suffix shared by all capability links.- Parameters:
ctx- the router context for translation- Returns:
- the tooltip suffix