Package com.logicaldoc.core.parser
Class ParserFactory
- java.lang.Object
-
- com.logicaldoc.core.parser.ParserFactory
-
public class ParserFactory extends Object
This is a factory, returning a parser instance for the given file.- Author:
- Michael Scholz
-
-
Constructor Summary
Constructors Constructor Description ParserFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Set<String>
getExtensions()
static Parser
getParser(String filename)
Method containing the lookup logicstatic Map<String,Parser>
getParsers()
static 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 Detail
-
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)
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
-
getParser
public static Parser getParser(String filename)
Method containing the lookup logic- Parameters:
filename
- name of the file- Returns:
- the right parser for the given file name
-
setAliases
public static void setAliases(String ext, String[] aliases)
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 ...)
-
-