Package org.apache.tika.parser.csv
Class TextAndCSVParser
- java.lang.Object
-
- org.apache.tika.parser.AbstractParser
-
- org.apache.tika.parser.AbstractEncodingDetectorParser
-
- org.apache.tika.parser.csv.TextAndCSVParser
-
- All Implemented Interfaces:
Serializable,org.apache.tika.parser.Parser
public class TextAndCSVParser extends org.apache.tika.parser.AbstractEncodingDetectorParserUnless theTikaCoreProperties.CONTENT_TYPE_OVERRIDEis set, this parser tries to assess whether the file is a text file, csv or tsv. If the detector detects regularity in column numbers and/or encapsulated cells, this parser will apply theCSVParser; otherwise, it will treat the contents as text.If there is a csv parse exception during detection, the parser sets the
HttpHeaders.CONTENT_TYPEtoMediaType.TEXT_PLAINand treats the file asMediaType.TEXT_PLAIN.If there is a csv parse exception during the parse, the parser writes what's left of the stream as if it were text and then throws an exception. As of this writing, the content that was buffered by the underlying
CSVParseris lost.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.tika.metadata.PropertyDELIMITER_PROPERTY
-
Constructor Summary
Constructors Constructor Description TextAndCSVParser()TextAndCSVParser(org.apache.tika.detect.EncodingDetector encodingDetector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<org.apache.tika.mime.MediaType>getSupportedTypes(org.apache.tika.parser.ParseContext context)voidparse(InputStream stream, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context)
-
-
-
Method Detail
-
getSupportedTypes
public Set<org.apache.tika.mime.MediaType> getSupportedTypes(org.apache.tika.parser.ParseContext context)
-
parse
public void parse(InputStream stream, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context) throws IOException, SAXException, org.apache.tika.exception.TikaException
- Throws:
IOExceptionSAXExceptionorg.apache.tika.exception.TikaException
-
-