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.models;
007
008import java.io.InputStream;
009import java.net.URI;
010import java.util.Collection;
011
012/**
013 * @author cabeer
014 * @since 9/19/14
015 */
016public interface Binary extends FedoraResource {
017
018    /**
019     * @return The InputStream of content associated with this datastream.
020     */
021    InputStream getContent();
022
023    /**
024     * @return The size in bytes of content associated with this datastream.
025     */
026    long getContentSize();
027
028    /**
029     * Get the pre-calculated content digest for the binary payload
030     * @return a URI with the format algorithm:value
031     */
032    Collection<URI> getContentDigests();
033
034    /**
035     * @return Whether or not this binary is a proxy to another resource
036     */
037    Boolean isProxy();
038
039    /**
040     * @return Whether or not this binary is a redirect to another resource
041     */
042    Boolean isRedirect();
043
044    /**
045     * @return the external url for this binary if present, or null.
046     */
047    String getExternalURL();
048
049    /**
050     * @return Get the external uri for this binary if present, or null
051     */
052    default URI getExternalURI() {
053        final var externalUrl = getExternalURL();
054        if (externalUrl == null) {
055            return null;
056        }
057        return URI.create(externalUrl);
058    }
059
060    /**
061     * @return The MimeType of content associated with this datastream.
062     */
063    String getMimeType();
064
065    /**
066     * Return the file name for the binary content
067     * @return original file name for the binary content, or the object's id.
068     */
069    String getFilename();
070}