001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.kernel.api.utils;
007
008import java.net.URI;
009import java.util.Set;
010
011/**
012 * @author bbpennel
013 * @since Feb 18, 2014
014 */
015public interface FixityResult {
016
017    /**
018     * The possible fixity states (which may be ORed together later)
019     */
020    enum FixityState {
021        SUCCESS, BAD_CHECKSUM, BAD_SIZE
022    }
023
024    /**
025     * Check if the fixity result matches the given checksum URI
026     *
027     * @param checksum the given checksum uri
028     * @return fixity result matches the given checksum URI
029     */
030    boolean matches(URI checksum);
031
032    /**
033     * Check if the fixity result matches the given size
034     *
035     * @param size the given size
036     * @return fixity result matches the given size
037     */
038    boolean matches(long size);
039
040    /**
041     * Does the fixity entry match the given size and checksum?
042     *
043     * @param size bitstream size in bytes
044     * @param checksum checksum URI
045     * @return true if both conditions matched
046     */
047    boolean matches(long size, URI checksum);
048
049    /**
050     * @param size the size
051     * @param checksum the checksum uri
052     * @return the status
053     */
054    Set<FixityState> getStatus(long size, URI checksum);
055
056    /**
057     * @return the computed size
058     */
059    long getComputedSize();
060
061    /**
062     * @return the computed checksum
063     */
064    URI getComputedChecksum();
065
066    /**
067     * @return the algorithm uses to compute the checksum
068     */
069    String getUsedAlgorithm();
070
071}