Package org.apache.tika.digest
Class InputStreamDigester
java.lang.Object
org.apache.tika.digest.InputStreamDigester
- All Implemented Interfaces:
Digester
Digester that uses
TikaInputStream.enableRewind() and TikaInputStream.rewind()
to read the entire stream for digesting, then rewind for subsequent processing.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddigest(TikaInputStream tis, Metadata metadata, ParseContext parseContext) Digests the TikaInputStream and stores the result in metadata.protected ProviderWhen subclassing this, becare to ensure that your provider is thread-safe (not likely) or return a new provider with each call.
-
Constructor Details
-
InputStreamDigester
- Parameters:
algorithm- name of the digest algorithm to retrieve from the ProvidermetadataKey- the full metadata key to use when storing the digest (e.g., "X-TIKA:digest:MD5" or "X-TIKA:digest:SHA256:BASE32")encoder- encoder to convert the byte array returned from the digester to a string
-
-
Method Details
-
getProvider
When subclassing this, becare to ensure that your provider is thread-safe (not likely) or return a new provider with each call.- Returns:
- provider to use to get the MessageDigest from the algorithm name. Default is to return null.
-
digest
public void digest(TikaInputStream tis, Metadata metadata, ParseContext parseContext) throws IOException Digests the TikaInputStream and stores the result in metadata.Uses
TikaInputStream.enableRewind()to ensure the stream can be rewound after digesting, then callsTikaInputStream.rewind()to reset the stream for subsequent processing.- Specified by:
digestin interfaceDigester- Parameters:
tis- TikaInputStream to digestmetadata- metadata in which to store the digest informationparseContext- ParseContext -- not actually used yet, but there for future expansion- Throws:
IOException- on IO problem or IllegalArgumentException if algorithm couldn't be found
-