Package org.apache.tika.parser.digest
Class InputStreamDigester
- java.lang.Object
-
- org.apache.tika.parser.digest.InputStreamDigester
-
- All Implemented Interfaces:
DigestingParser.Digester
public class InputStreamDigester extends java.lang.Object implements DigestingParser.Digester
-
-
Constructor Summary
Constructors Constructor Description InputStreamDigester(int markLimit, java.lang.String algorithm, java.lang.String algorithmKeyName, DigestingParser.Encoder encoder)
InputStreamDigester(int markLimit, java.lang.String algorithm, DigestingParser.Encoder encoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
digest(java.io.InputStream is, Metadata metadata, ParseContext parseContext)
Digests an InputStream and sets the appropriate value(s) in the metadata.
-
-
-
Constructor Detail
-
InputStreamDigester
public InputStreamDigester(int markLimit, java.lang.String algorithm, DigestingParser.Encoder encoder)
-
InputStreamDigester
public InputStreamDigester(int markLimit, java.lang.String algorithm, java.lang.String algorithmKeyName, DigestingParser.Encoder encoder)
- Parameters:
markLimit
- limit in bytes to allow for mark/reset. If the inputstream is longer than this limit, the stream will be reset and then spooled to a temporary file. Throws IllegalArgumentException if < 0.algorithm
- name of the digest algorithm to retrieve from the ProvideralgorithmKeyName
- name of the algorithm to store as part of the key in the metadata whendigest(InputStream, Metadata, ParseContext)
is calledencoder
- encoder to convert the byte array returned from the digester to a string
-
-
Method Detail
-
digest
public void digest(java.io.InputStream is, Metadata metadata, ParseContext parseContext) throws java.io.IOException
Description copied from interface:DigestingParser.Digester
Digests an InputStream and sets the appropriate value(s) in the metadata. The Digester is also responsible for marking and resetting the stream.The given stream is guaranteed to support the
mark feature
and the detector is expected tomark
the stream before reading any bytes from it, and toreset
the stream before returning. The stream must not be closed by the detector.- Specified by:
digest
in interfaceDigestingParser.Digester
- Parameters:
is
- InputStream to digest. Best to use a TikaInputStream because of potential need to spool to disk. InputStream must support mark/reset.metadata
- metadata in which to store the digest informationparseContext
- ParseContext -- not actually used yet, but there for future expansion- Throws:
java.io.IOException
- on IO problem or IllegalArgumentException if algorithm couldn't be found
-
-