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 * @param start start index of the range, inclusive 025 * @param end end index of the range, inclusive 026 * @return The InputStream of the range of bytes of content associated with this datastream. 027 */ 028 InputStream getRange(final long start, final long end); 029 030 /** 031 * @return The size in bytes of content associated with this datastream. 032 */ 033 long getContentSize(); 034 035 /** 036 * Get the pre-calculated content digest for the binary payload 037 * @return a URI with the format algorithm:value 038 */ 039 Collection<URI> getContentDigests(); 040 041 /** 042 * @return Whether or not this binary is a proxy to another resource 043 */ 044 Boolean isProxy(); 045 046 /** 047 * @return Whether or not this binary is a redirect to another resource 048 */ 049 Boolean isRedirect(); 050 051 /** 052 * @return the external url for this binary if present, or null. 053 */ 054 String getExternalURL(); 055 056 /** 057 * @return Get the external uri for this binary if present, or null 058 */ 059 default URI getExternalURI() { 060 final var externalUrl = getExternalURL(); 061 if (externalUrl == null) { 062 return null; 063 } 064 return URI.create(externalUrl); 065 } 066 067 /** 068 * @return The MimeType of content associated with this datastream. 069 */ 070 String getMimeType(); 071 072 /** 073 * Return the file name for the binary content 074 * @return original file name for the binary content, or the object's id. 075 */ 076 String getFilename(); 077}