Package com.logicaldoc.core.parser
Class ParserFactory
java.lang.Object
com.logicaldoc.core.parser.ParserFactory
This is a factory, returning a parser instance for the given file.
- Author:
- Michael Scholz
-
Method Summary
Modifier and TypeMethodDescriptionstatic Parser
Method containing the lookup logicstatic void
init()
Registers all parsers from extension pointsstatic String
parse
(InputStream input, String filename, String encoding, Locale locale, long tenantId, Document document, String fileVersion) Gets the proper parser and parse the given contentstatic void
setAliases
(String ext, String[] aliases) Adds new aliases for the specified extension.
-
Method Details
-
init
public static void init()Registers all parsers from extension points -
parse
public static String parse(InputStream input, String filename, String encoding, Locale locale, long tenantId, Document document, String fileVersion) throws ParsingException Gets the proper parser and parse the given content- Parameters:
input
- the input contents as streamfilename
- name of the fileencoding
- encoding of the streamlocale
- the localetenantId
- identifier of the tenantdocument
- the document the file belongs to (optional)fileVersion
- the file version being processed (optional)- Returns:
- the text extracted from the input
- Throws:
ParsingException
- error in the parsing
-
getParser
Method containing the lookup logic- Parameters:
filename
- name of the file- Returns:
- the right parser for the given file name
-
getExtensions
-
getParsers
-
setAliases
Adds new aliases for the specified extension.Each alias is saved as property parser.alias.<ext>
example: parser.alias.odt = test, acme
In this case an extension 'test' will be treated as 'odt'- Parameters:
ext
- Must be one of the registered extensionsaliases
- Array of extension aliases (eg. test, acme ...)
-