Package org.apache.tika.mime
Class MimeTypesFactory
- java.lang.Object
-
- org.apache.tika.mime.MimeTypesFactory
-
public class MimeTypesFactory extends Object
Creates instances of MimeTypes.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCUSTOM_MIMES_SYS_PROPSystem property to set a path to an additional external custom mimetypes XML file to be loaded.
-
Constructor Summary
Constructors Constructor Description MimeTypesFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MimeTypescreate()Creates an empty instance; same as calling new MimeTypes().static MimeTypescreate(InputStream stream)static MimeTypescreate(InputStream... inputStreams)Creates and returns a MimeTypes instance from the specified input stream.static MimeTypescreate(String filePath)Creates and returns a MimeTypes instance from the specified file path, as interpreted by the class loader in getResource().static MimeTypescreate(String coreFilePath, String extensionFilePath)Creates and returns a MimeTypes instance.static MimeTypescreate(String coreFilePath, String extensionFilePath, ClassLoader classLoader)Creates and returns a MimeTypes instance.static MimeTypescreate(URL url)static MimeTypescreate(URL... urls)Creates and returns a MimeTypes instance from the resource at the location specified by the URL.static MimeTypescreate(Document document)Creates and returns a MimeTypes instance from the specified document.
-
-
-
Field Detail
-
CUSTOM_MIMES_SYS_PROP
public static final String CUSTOM_MIMES_SYS_PROP
System property to set a path to an additional external custom mimetypes XML file to be loaded.- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static MimeTypes create()
Creates an empty instance; same as calling new MimeTypes().- Returns:
- an empty instance
-
create
public static MimeTypes create(Document document) throws MimeTypeException
Creates and returns a MimeTypes instance from the specified document.- Throws:
MimeTypeException- if the type configuration is invalid
-
create
public static MimeTypes create(InputStream... inputStreams) throws IOException, MimeTypeException
Creates and returns a MimeTypes instance from the specified input stream. Does not close the input stream(s).- Throws:
IOException- if the stream can not be readMimeTypeException- if the type configuration is invalid
-
create
public static MimeTypes create(InputStream stream) throws IOException, MimeTypeException
- Throws:
IOExceptionMimeTypeException- See Also:
create(InputStream...)
-
create
public static MimeTypes create(URL... urls) throws IOException, MimeTypeException
Creates and returns a MimeTypes instance from the resource at the location specified by the URL. Opens and closes the InputStream from the URL. If multiple URLs are supplied, then they are loaded in turn.- Throws:
IOException- if the URL can not be accessedMimeTypeException- if the type configuration is invalid
-
create
public static MimeTypes create(URL url) throws IOException, MimeTypeException
- Throws:
IOExceptionMimeTypeException- See Also:
create(URL...)
-
create
public static MimeTypes create(String filePath) throws IOException, MimeTypeException
Creates and returns a MimeTypes instance from the specified file path, as interpreted by the class loader in getResource().- Throws:
IOException- if the file can not be accessedMimeTypeException- if the type configuration is invalid
-
create
public static MimeTypes create(String coreFilePath, String extensionFilePath) throws IOException, MimeTypeException
Creates and returns a MimeTypes instance. The core mimetypes will be loaded from the specified file path, and any custom override mimetypes found will loaded afterwards. The file paths will be interpreted by the default class loader in getResource().- Parameters:
coreFilePath- The main MimeTypes file to loadextensionFilePath- The name of extension MimeType files to load afterwards- Throws:
IOException- if the file can not be accessedMimeTypeException- if the type configuration is invalid
-
create
public static MimeTypes create(String coreFilePath, String extensionFilePath, ClassLoader classLoader) throws IOException, MimeTypeException
Creates and returns a MimeTypes instance. The core mimetypes will be loaded from the specified file path, and any custom override mimetypes found will loaded afterwards. The file paths will be interpreted by the specified class loader in getResource(). It will also load custom mimetypes from the system propertyCUSTOM_MIMES_SYS_PROP, if specified.- Parameters:
coreFilePath- The main MimeTypes file to loadextensionFilePath- The name of extension MimeType files to load afterwards- Throws:
IOException- if the file can not be accessedMimeTypeException- if the type configuration is invalid
-
-