Class NTxHighlights

java.lang.Object
net.thevpc.ntexup.api.document.node.NTxHighlights

public final class NTxHighlights extends Object
Access + helpers for the MVC search-highlight model (NTxNodeHighlight).

Highlights are stored in the node's user-object map (survives render-cache invalidation and node cloning, never serialized with the document). All matching goes through normalize(String) so that case, diacritics, markup separators (\ _ [[...]]), punctuation and whitespace never prevent a hit (\lambda_0 and lambda both normalize into space-separated words).

See Also:
  • Method Details

    • get

      public static List<NTxNodeHighlight> get(NTxNode node)
      Returns:
      the mutable list of highlights bound to the node (never null, may be empty)
    • set

      public static void set(NTxNode node, List<NTxNodeHighlight> highlights)
      Binds (or replaces) the highlight list of a node. A null or empty list removes the entry entirely.
    • clear

      public static void clear(NTxNode node)
      Removes every highlight bound to the node.
    • hasHighlights

      public static boolean hasHighlights(NTxNode node)
      True when the node carries at least one highlight.
    • normalize

      public static String normalize(String raw)
      Canonical normalization used by search, indexing and painting:
      • NFD decomposition, combining marks dropped (diacritic insensitive: schéma → schema);
      • letters/digits kept, lowercased;
      • everything else (whitespace, punctuation, backslashes, underscores, brackets...) becomes a single space, so \lambda_0 → " lambda 0" and the word lambda still matches inside it.
      Returns:
      normalized text, never null
    • needlesOf

      public static List<String> needlesOf(String query)
      Needles used for a user query: the whole normalized (trimmed) query first, then its whitespace-separated words. A single-word query yields a single needle.
      Returns:
      normalized needles, possibly empty for blank input
    • findMatches

      public static List<int[]> findMatches(String raw, String needle)
      Finds every raw [start,end) range of raw whose text matches needle under normalize(String). Indexes map back to the raw (non-normalized) string so callers can slice it directly.
      Returns:
      list of int[]{start,end} ranges (possibly empty)
    • paintWholeNode

      public static void paintWholeNode(NTxNode node, NTxRendererContext ctx)
      Paints every whole-node span of the node over its layout bounds. Called by net.thevpc.ntexup.engine.renderer.NTxNodeRendererBase after the node content is drawn; does nothing unless the host enabled the NTxRendererContext.CAPABILITY_SEARCH_HIGHLIGHTS capability (the screen viewer), so PDF/HTML/image renders stay clean.