Class AbstractParser
- All Implemented Interfaces:
Parser
- Direct Known Subclasses:
AbiWordParser
,CatchAllParser
,DummyParser
,EpubParser
,HTMLParser
,KOfficeParser
,OpenOfficeParser
,PDFParser
,PPTParser
,RarParser
,RTFParser
,SevenZipParser
,TarParser
,TXTParser
,XLSParser
,XMLParser
,ZABWParser
,ZipParser
- Since:
- 3.5
- Author:
- Marco Meschieri - LogicalDOC
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
countPages
(File file, String filename) Same as the otherParser.countPages(InputStream, String)
, but use this when you have a file rather than a stream.int
countPages
(InputStream input, String filename) Counts the number of pages of the given binary document.Same asParser.parse(InputStream, String, String, Locale, String)
, use this when you have a file rather than a stream.parse
(File file, String filename, String encoding, Locale locale, String tenant, Document document, String fileVersion) Same asParser.parse(InputStream, ParseParameters)
, but use this when you have a file rather than a stream.parse
(InputStream input, ParseParameters parameters) Extracts content for the text content of the given binary document.Extracts content for the text content of the given binary document.
-
Constructor Details
-
AbstractParser
public AbstractParser()
-
-
Method Details
-
parse
public String parse(File file, String filename, String encoding, Locale locale, String tenant) throws ParseException Description copied from interface:Parser
Same asParser.parse(InputStream, String, String, Locale, String)
, use this when you have a file rather than a stream.- Specified by:
parse
in interfaceParser
- Parameters:
file
- the filefilename
- name of the fileencoding
- character encodinglocale
- the localetenant
- name of the tenant- Returns:
- the extracted text
- Throws:
ParseException
- error in the parsing
-
parse
public String parse(File file, String filename, String encoding, Locale locale, String tenant, Document document, String fileVersion) throws ParseException Description copied from interface:Parser
Same asParser.parse(InputStream, ParseParameters)
, but use this when you have a file rather than a stream.- Specified by:
parse
in interfaceParser
- Parameters:
file
- the filefilename
- name of the fileencoding
- character encodinglocale
- the localetenant
- name of the tenantdocument
- the document the file belongs to (optional)fileVersion
- the file version being processed (optional)- Returns:
- the extracted text
- Throws:
ParseException
- error in the parsing
-
parse
public String parse(InputStream input, String filename, String encoding, Locale locale, String tenant) throws ParseException Description copied from interface:Parser
Extracts content for the text content of the given binary document. The content type and character encoding (if available and applicable) are given as arguments.The implementation can choose either to read and parse the given document immediately or to return a reader that does it incrementally. The only constraint is that the implementation must close the given stream latest when the returned reader is closed. The caller on the other hand is responsible for closing the returned reader.
The implementation should only throw an exception on transient errors, i.e. when it can expect to be able to successfully extract the text content of the same binary at another time. An effort should be made to recover from syntax errors and other similar problems.
This method should be thread-safe, i.e. it is possible that this method is invoked simultaneously by different threads to extract the text content of different documents. On the other hand the returned reader does not need to be thread-safe.
The parsing has to be completed before the seconds specified in the parser.timeout config. property.
- Specified by:
parse
in interfaceParser
- Parameters:
input
- binary content from which to extract the textfilename
- name of the fileencoding
- character encodinglocale
- the localetenant
- name of the tenant- Returns:
- the extracted text
- Throws:
ParseException
- error in the parsing
-
parse
Description copied from interface:Parser
Extracts content for the text content of the given binary document. The content type and character encoding (if available and applicable) are given as arguments.The implementation can choose either to read and parse the given document immediately or to return a reader that does it incrementally. The only constraint is that the implementation must close the given stream latest when the returned reader is closed. The caller on the other hand is responsible for closing the returned reader.
The implementation should only throw an exception on transient errors, i.e. when it can expect to be able to successfully extract the text content of the same binary at another time. An effort should be made to recover from syntax errors and other similar problems.
This method should be thread-safe, i.e. it is possible that this method is invoked simultaneously by different threads to extract the text content of different documents. On the other hand the returned reader does not need to be thread-safe.
The parsing has to be completed before the seconds specified in the parser.timeout config. property.
- Specified by:
parse
in interfaceParser
- Parameters:
input
- binary content from which to extract the textparameters
- TODO- Returns:
- the extracted text
- Throws:
ParseException
- error in the parsing
-
countPages
Description copied from interface:Parser
Counts the number of pages of the given binary document.- Specified by:
countPages
in interfaceParser
- Parameters:
input
- binary content from which to extract the textfilename
- name of the file- Returns:
- the number of pages
-
countPages
Description copied from interface:Parser
Same as the otherParser.countPages(InputStream, String)
, but use this when you have a file rather than a stream.- Specified by:
countPages
in interfaceParser
- Parameters:
file
- the filefilename
- name of the file- Returns:
- the number of pages
-