Package org.apache.tika.utils
Class ParserUtils
- java.lang.Object
-
- org.apache.tika.utils.ParserUtils
-
public class ParserUtils extends Object
Helper util methods for Parsers themselves.
-
-
Field Summary
Fields Modifier and Type Field Description static Property
EMBEDDED_PARSER
-
Constructor Summary
Constructors Constructor Description ParserUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Metadata
cloneMetadata(Metadata m)
Does a deep clone of a Metadata object.static InputStream
ensureStreamReReadable(InputStream stream, TemporaryResources tmp)
Ensures that the Stream will be able to be re-read, by buffering to a temporary file if required.static String
getParserClassname(Parser parser)
Identifies the real class name of theParser
, unwrapping anyParserDecorator
decorations on top of it.static void
recordParserDetails(String parserClassName, Metadata metadata)
static void
recordParserDetails(Parser parser, Metadata metadata)
static void
recordParserFailure(Parser parser, Throwable failure, Metadata metadata)
static InputStream
streamResetForReRead(InputStream stream, TemporaryResources tmp)
Resets the givenTikaInputStream
(checked byensureStreamReReadable(InputStream, TemporaryResources)
) so that it can be re-read again.
-
-
-
Field Detail
-
EMBEDDED_PARSER
public static final Property EMBEDDED_PARSER
-
-
Method Detail
-
cloneMetadata
public static Metadata cloneMetadata(Metadata m)
Does a deep clone of a Metadata object.
-
getParserClassname
public static String getParserClassname(Parser parser)
Identifies the real class name of theParser
, unwrapping anyParserDecorator
decorations on top of it.
-
recordParserDetails
public static void recordParserDetails(String parserClassName, Metadata metadata)
-
recordParserFailure
public static void recordParserFailure(Parser parser, Throwable failure, Metadata metadata)
-
ensureStreamReReadable
public static InputStream ensureStreamReReadable(InputStream stream, TemporaryResources tmp) throws IOException
Ensures that the Stream will be able to be re-read, by buffering to a temporary file if required. Streams that are automatically OK includeTikaInputStream
s created from Files or InputStreamFactories, andRereadableInputStream
.- Throws:
IOException
-
streamResetForReRead
public static InputStream streamResetForReRead(InputStream stream, TemporaryResources tmp) throws IOException
Resets the givenTikaInputStream
(checked byensureStreamReReadable(InputStream, TemporaryResources)
) so that it can be re-read again.- Throws:
IOException
-
-