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