001/*
002 * Copyright 2015 DuraSpace, Inc.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.fcrepo.kernel.api.utils;
017
018import java.net.URI;
019import java.util.Set;
020
021/**
022 * @author bbpennel
023 * @since Feb 18, 2014
024 */
025public interface FixityResult {
026
027    /**
028     * The possible fixity states (which may be ORed together later)
029     */
030    public static enum FixityState {
031        SUCCESS, BAD_CHECKSUM, BAD_SIZE
032    }
033
034    /**
035     * Get the identifier for the entry's store
036     * @return String
037     */
038    String getStoreIdentifier();
039
040    /**
041     * Check if the fixity result matches the given checksum URI
042     *
043     * @param checksum the given checksum uri
044     * @return fixity result matches the given checksum URI
045     */
046    boolean matches(URI checksum);
047
048    /**
049     * Check if the fixity result matches the given size
050     *
051     * @param size the given size
052     * @return fixity result matches the given size
053     */
054    boolean matches(long size);
055
056    /**
057     * Does the fixity entry match the given size and checksum?
058     *
059     * @param size bitstream size in bytes
060     * @param checksum checksum URI
061     * @return true if both conditions matched
062     */
063    boolean matches(long size, URI checksum);
064
065    /**
066     * @param size the size
067     * @param checksum the checksum uri
068     * @return the status
069     */
070    Set<FixityState> getStatus(long size, URI checksum);
071
072    /**
073     * @return the computed size
074     */
075    long getComputedSize();
076
077    /**
078     * @return the computed checksum
079     */
080    URI getComputedChecksum();
081
082}