Class SearchIndex


  • public class SearchIndex
    extends java.lang.Object
    A searchindex for searching through a book.
    • Field Detail

      • log

        private static final org.slf4j.Logger log
      • NBSP

        public static int NBSP
      • WHITESPACE_PATTERN

        private static final java.util.regex.Pattern WHITESPACE_PATTERN
      • REMOVE_ACCENT_PATTERN

        private static final java.util.regex.Pattern REMOVE_ACCENT_PATTERN
      • book

        private Book book
    • Constructor Detail

      • SearchIndex

        public SearchIndex()
      • SearchIndex

        public SearchIndex​(Book book)
    • Method Detail

      • getBook

        public Book getBook()
      • initBook

        public void initBook​(Book book)
      • doSearch

        public SearchResults doSearch​(java.lang.String searchTerm)
      • getSearchContent

        public static java.lang.String getSearchContent​(Resource resource)
      • getSearchContent

        public static java.lang.String getSearchContent​(java.io.Reader content)
      • isHtmlWhitespace

        private static boolean isHtmlWhitespace​(int c)
        Checks whether the given character is a java whitespace or a non-breaking-space ( ).
        Parameters:
        c -
        Returns:
        whether the given character is a java whitespace or a non-breaking-space ( ).
      • unicodeTrim

        public static java.lang.String unicodeTrim​(java.lang.String text)
      • cleanText

        public static java.lang.String cleanText​(java.lang.String text)
        Turns html encoded text into plain text. Replaces ö type of expressions into ¨
        Removes accents
        Replaces multiple whitespaces with a single space.
        Parameters:
        text -
        Returns:
        html encoded text turned into plain text.
      • doSearch

        protected static java.util.List<SearchResult> doSearch​(java.lang.String searchTerm,
                                                               java.lang.String content,
                                                               Resource resource)