001/*
002 *  Copyright 2010 Anyware Services
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.ametys.plugins.repository.metadata;
017
018import java.io.InputStream;
019import java.util.Date;
020
021import org.ametys.plugins.repository.AmetysRepositoryException;
022
023/**
024 * Interface representing a binary resource.
025 */
026public interface Resource
027{
028    /**
029     * Returns the data mime-type.
030     * @return the data mime-type.
031     * @throws AmetysRepositoryException if an error occurs.
032     */
033    public String getMimeType() throws AmetysRepositoryException;
034    
035    /**
036     * Returns the data stream.
037     * @return the data stream.
038     * @throws AmetysRepositoryException if an error occurs.
039     */
040    public InputStream getInputStream() throws AmetysRepositoryException;
041    
042    /**
043     * Returns the length of the data stream.
044     * @return the length of the data stream.
045     * @throws AmetysRepositoryException if an error occurs.
046     */
047    public long getLength() throws AmetysRepositoryException;
048        
049    /**
050     * Returns the encoding if the data stream, if it is a character stream.
051     * @return the encoding if the data stream or <code>null</code> if not available.
052     * @throws AmetysRepositoryException if an error occurs.
053     */
054    public String getEncoding() throws AmetysRepositoryException;
055    
056    /**
057     * Returns the last modification date.
058     * @return the last modification date.
059     * @throws AmetysRepositoryException if an error occurs.
060     */
061    public Date getLastModified() throws AmetysRepositoryException;
062}