Class HtmlHighlighter

  • All Implemented Interfaces:
    Highlighter

    public class HtmlHighlighter
    extends java.lang.Object
    implements Highlighter
    Highlights occurrences of values in a string by wrapping them with a HTML tag.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected static class  HtmlHighlighter.Range  
    • Constructor Summary

      Constructors 
      Constructor Description
      HtmlHighlighter​(java.lang.String startTag, java.lang.String endTag)
      Create a highlighter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Set<HtmlHighlighter.Range> findMatches​(java.lang.String lowerValue, java.util.Collection<java.lang.String> highlightText)  
      java.lang.String highlight​(java.lang.String value, java.util.Collection<java.lang.String> highlightText)
      Apply highlighting to a string.
      protected java.lang.String highlightRanges​(java.lang.String value, java.util.Set<HtmlHighlighter.Range> ranges)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HtmlHighlighter

        public HtmlHighlighter​(java.lang.String startTag,
                               java.lang.String endTag)
        Create a highlighter.
        Parameters:
        startTag - the start tag to use for highlighting
        endTag - the end tag to use for highlighting
    • Method Detail

      • highlight

        public java.lang.String highlight​(java.lang.String value,
                                          java.util.Collection<java.lang.String> highlightText)
        Description copied from interface: Highlighter
        Apply highlighting to a string.
        Specified by:
        highlight in interface Highlighter
        Parameters:
        value - the string to highlight
        highlightText - the substrings to highlight within value
        Returns:
        an HTML string with values in highlightText wrapped by the start and end tags.
      • highlightRanges

        protected java.lang.String highlightRanges​(java.lang.String value,
                                                   java.util.Set<HtmlHighlighter.Range> ranges)
      • findMatches

        protected java.util.Set<HtmlHighlighter.Range> findMatches​(java.lang.String lowerValue,
                                                                   java.util.Collection<java.lang.String> highlightText)