001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.kernel.api.models; 019 020import java.io.InputStream; 021import java.net.URI; 022import java.util.Collection; 023 024/** 025 * @author cabeer 026 * @since 9/19/14 027 */ 028public interface Binary extends FedoraResource { 029 030 /** 031 * @return The InputStream of content associated with this datastream. 032 */ 033 InputStream getContent(); 034 035 /** 036 * @return The size in bytes of content associated with this datastream. 037 */ 038 long getContentSize(); 039 040 /** 041 * Get the pre-calculated content digest for the binary payload 042 * @return a URI with the format algorithm:value 043 */ 044 Collection<URI> getContentDigests(); 045 046 /** 047 * @return Whether or not this binary is a proxy to another resource 048 */ 049 Boolean isProxy(); 050 051 /** 052 * @return Whether or not this binary is a redirect to another resource 053 */ 054 Boolean isRedirect(); 055 056 /** 057 * @return the external url for this binary if present, or null. 058 */ 059 String getExternalURL(); 060 061 /** 062 * @return Get the external uri for this binary if present, or null 063 */ 064 default URI getExternalURI() { 065 final var externalUrl = getExternalURL(); 066 if (externalUrl == null) { 067 return null; 068 } 069 return URI.create(externalUrl); 070 } 071 072 /** 073 * @return The MimeType of content associated with this datastream. 074 */ 075 String getMimeType(); 076 077 /** 078 * Return the file name for the binary content 079 * @return original file name for the binary content, or the object's id. 080 */ 081 String getFilename(); 082}