public class CommonsDigester extends Object implements DigestingParser.Digester
DigestingParser.Digester
that relies on commons.codec.digest.DigestUtils to calculate digest hashes.
This digester tries to use the regular mark/reset protocol on the InputStream. However, this wraps an internal BoundedInputStream, and if the InputStream is not fully read, then this will reset the stream and spool the InputStream to disk (via TikaInputStream) and then digest the file.
If a TikaInputStream is passed in and it has an underlying file that is longer
than the markLimit
, then this digester digests the file directly.
Modifier and Type | Class and Description |
---|---|
static class |
CommonsDigester.DigestAlgorithm |
Constructor and Description |
---|
CommonsDigester(int markLimit,
CommonsDigester.DigestAlgorithm... algorithms) |
Modifier and Type | Method and Description |
---|---|
void |
digest(InputStream is,
Metadata m,
ParseContext parseContext)
Digests an InputStream and sets the appropriate value(s) in the metadata.
|
static CommonsDigester.DigestAlgorithm[] |
parse(String s) |
public CommonsDigester(int markLimit, CommonsDigester.DigestAlgorithm... algorithms)
public void digest(InputStream is, Metadata m, ParseContext parseContext) throws IOException
DigestingParser.Digester
The given stream is guaranteed to support the
mark feature
and the detector
is expected to mark
the stream before
reading any bytes from it, and to reset
the stream before returning. The stream must not be closed by the
detector.
digest
in interface DigestingParser.Digester
is
- InputStream to digestm
- Metadata to set the values forparseContext
- ParseContextIOException
public static CommonsDigester.DigestAlgorithm[] parse(String s)
s
- comma-delimited (no space) list of algorithms to use: md5,sha256Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.