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 ofMIMETypeDetectorbased on Apache Tika.- Author:
- Michele Mostarda (michele.mostarda@gmail.com), Davide Palmisano (dpalmisano@gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description static StringCSV_MIMETYPEstatic StringRESOURCE_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 booleancheckCSVFormat(InputStream is)Checks if the stream contains a valid CSV pattern.static booleancheckN3Format(InputStream is)Checks if the stream contains the N3 triple patterns.static booleancheckNQuadsFormat(InputStream is)Checks if the stream contains the NQuads patterns.static booleancheckTurtleFormat(InputStream is)Checks if the stream contains Turtle triple patterns.MIMETypeguessMIMEType(String fileName, InputStream input, MIMEType mimeTypeFromMetadata)Estimates theMIMEtype 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:
trueif N3 patterns are detected,falseotherwise.- 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:
trueif N3 patterns are detected,falseotherwise.- 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:
trueif Turtle patterns are detected,falseotherwise.- 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:
trueif CSV patterns are detected,falseotherwise.- Throws:
IOException- if there is an error checking theInputStream
-
guessMIMEType
public MIMEType guessMIMEType(String fileName, InputStream input, MIMEType mimeTypeFromMetadata)
Estimates theMIMEtype of the content of input file. The input stream must be resettable.- Specified by:
guessMIMETypein interfaceMIMETypeDetector- Parameters:
fileName- name of the data source.input-nullor a resettable input stream containing data.mimeTypeFromMetadata- mimetype declared in metadata.- Returns:
- the supposed mime type or
nullif nothing appropriate found. - Throws:
IllegalArgumentException- if input is notnulland is not resettable.
-
-