Package org.apache.any23.mime
Class TikaMIMETypeDetector
- java.lang.Object
-
- org.apache.any23.mime.TikaMIMETypeDetector
-
- All Implemented Interfaces:
MIMETypeDetector
public class TikaMIMETypeDetector extends Object implements MIMETypeDetector
Implementation ofMIMETypeDetector
based on Apache Tika.- Author:
- Michele Mostarda (michele.mostarda@gmail.com), Davide Palmisano (dpalmisano@gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description static String
CSV_MIMETYPE
static String
RESOURCE_NAME
-
Constructor Summary
Constructors Constructor Description TikaMIMETypeDetector()
TikaMIMETypeDetector(Purifier purifier)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
checkCSVFormat(InputStream is)
Checks if the stream contains a valid CSV pattern.static boolean
checkN3Format(InputStream is)
Checks if the stream contains the N3 triple patterns.static boolean
checkNQuadsFormat(InputStream is)
Checks if the stream contains the NQuads patterns.static boolean
checkTurtleFormat(InputStream is)
Checks if the stream contains Turtle triple patterns.MIMEType
guessMIMEType(String fileName, InputStream input, MIMEType mimeTypeFromMetadata)
Estimates theMIME
type of the content of input file.
-
-
-
Field Detail
-
CSV_MIMETYPE
public static final String CSV_MIMETYPE
- See Also:
- Constant Field Values
-
RESOURCE_NAME
public static final String RESOURCE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TikaMIMETypeDetector
public TikaMIMETypeDetector(Purifier purifier)
-
TikaMIMETypeDetector
public TikaMIMETypeDetector()
-
-
Method Detail
-
checkN3Format
public static boolean checkN3Format(InputStream is) throws IOException
Checks if the stream contains the N3 triple patterns.- Parameters:
is
- input stream to be verified.- Returns:
true
if N3 patterns are detected,false
otherwise.- Throws:
IOException
- if there is an error checking theInputStream
-
checkNQuadsFormat
public static boolean checkNQuadsFormat(InputStream is) throws IOException
Checks if the stream contains the NQuads patterns.- Parameters:
is
- input stream to be verified.- Returns:
true
if N3 patterns are detected,false
otherwise.- Throws:
IOException
- if there is an error checking theInputStream
-
checkTurtleFormat
public static boolean checkTurtleFormat(InputStream is) throws IOException
Checks if the stream contains Turtle triple patterns.- Parameters:
is
- input stream to be verified.- Returns:
true
if Turtle patterns are detected,false
otherwise.- Throws:
IOException
- if there is an error checking theInputStream
-
checkCSVFormat
public static boolean checkCSVFormat(InputStream is) throws IOException
Checks if the stream contains a valid CSV pattern.- Parameters:
is
- input stream to be verified.- Returns:
true
if CSV patterns are detected,false
otherwise.- Throws:
IOException
- if there is an error checking theInputStream
-
guessMIMEType
public MIMEType guessMIMEType(String fileName, InputStream input, MIMEType mimeTypeFromMetadata)
Estimates theMIME
type of the content of input file. The input stream must be resettable.- Specified by:
guessMIMEType
in interfaceMIMETypeDetector
- Parameters:
fileName
- name of the data source.input
-null
or a resettable input stream containing data.mimeTypeFromMetadata
- mimetype declared in metadata.- Returns:
- the supposed mime type or
null
if nothing appropriate found. - Throws:
IllegalArgumentException
- if input is notnull
and is not resettable.
-
-