com.groupdocs.parser

Interfaces

Classes

Exceptions

com.groupdocs.parser

Class FictionBookTextExtractor

  • All Implemented Interfaces:
    IHighlightExtractor, IRegexSearchable, ISearchable, IStructuredExtractor, AutoCloseable


    public final class FictionBookTextExtractor
    extends TextExtractor
    implements ISearchable, IRegexSearchable, IHighlightExtractor, IStructuredExtractor

    Provides the text extractor for FB2 (FictionBook) documents.

    Extracts a line of characters from a document:

     // Create a text extractor for FB2 (FictionBook) documents
     TextExtractor extractor = new FictionBookTextExtractor(stream);
     // Extract a line of the text
     String line = extractor.extractLine();
     // If the line is null, then the end of the file is reached
     while (line != null) {
         // Print a line to the console
         System.out.println(line);
         // Extract another line
         line = extractor.extractLine();
     }
      

    Extracts all characters from a document:

     // Create a text extractor for FB2 (FictionBook) documents
     TextExtractor extractor = new FictionBookTextExtractor(stream);
     // Extract a text
     System.out.println(extractor.extractAll());
      
    • Constructor Detail

      • FictionBookTextExtractor

        public FictionBookTextExtractor(String fileName)

        Initializes a new instance of the FictionBookTextExtractor class.

        Parameters:
        fileName - The path to the file.
        Throws:
        UnsupportedDocumentFormatException - File format isn't supported.
      • FictionBookTextExtractor

        public FictionBookTextExtractor(InputStream stream)

        Initializes a new instance of the FictionBookTextExtractor class.

        Parameters:
        stream - The stream of the document.
        Throws:
        UnsupportedDocumentFormatException - File format isn't supported.
    • Method Detail

      • extractHighlights

        public List<String> extractHighlights(HighlightOptions... highlightOptions)

        Extracts highlights.

        Specified by:
        extractHighlights in interface IHighlightExtractor
        Parameters:
        highlightOptions - A collection of HighlightOptions.
        Returns:
        A collection of strings that represent highlights. If no highlight is found, a collection is empty.
      • search

        public void search(SearchOptions options,
                  ISearchHandler handler,
                  List<String> keywords)

        Searches the keywords.

        Specified by:
        search in interface ISearchable
        Parameters:
        options - Options for searching.
        handler - An instance of the search handler.
        keywords - A collection of words to search.
      • search

        public void search(SearchOptions options,
                  ISearchHandler handler,
                  ISearchEngine searchEngine,
                  List<String> keywords)

        Searches the keywords.

        Specified by:
        search in interface ISearchable
        Parameters:
        options - Options for searching.
        handler - An instance of the search handler.
        searchEngine - An instance of the search engine.
        keywords - A collection of words to search.
      • reset

        public void reset()

        Resets the current document.


        Resets the cursor's position. ExtractLine method will return the first line of the document.

        Overrides:
        reset in class TextExtractor
      • dispose

        protected void dispose(boolean disposing)

        Releases the unmanaged resources used by the extractor.

        Overrides:
        dispose in class TextExtractor
        Parameters:
        disposing - A boolean true if invoked from Dispose; otherwise, false.
      • prepareLine

        protected String prepareLine()

        Returns a line of the text.

        Specified by:
        prepareLine in class TextExtractor
        Returns:
        A string that represents a line of the text, or null if all characters have been read.