[6785] | 1 | /**************************************************************** |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one * |
---|
| 3 | * or more contributor license agreements. See the NOTICE file * |
---|
| 4 | * distributed with this work for additional information * |
---|
| 5 | * regarding copyright ownership. The ASF licenses this file * |
---|
| 6 | * to you under the Apache License, Version 2.0 (the * |
---|
| 7 | * "License"); you may not use this file except in compliance * |
---|
| 8 | * with the License. You may obtain a copy of the License at * |
---|
| 9 | * * |
---|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 * |
---|
| 11 | * * |
---|
| 12 | * Unless required by applicable law or agreed to in writing, * |
---|
| 13 | * software distributed under the License is distributed on an * |
---|
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * |
---|
| 15 | * KIND, either express or implied. See the License for the * |
---|
| 16 | * specific language governing permissions and limitations * |
---|
| 17 | * under the License. * |
---|
| 18 | ****************************************************************/ |
---|
| 19 | |
---|
| 20 | package org.apache.james.mime4j.storage; |
---|
| 21 | |
---|
| 22 | import java.io.IOException; |
---|
| 23 | import java.io.InputStream; |
---|
| 24 | |
---|
| 25 | /** |
---|
| 26 | * Can be used to read data that has been stored by a {@link StorageProvider}. |
---|
| 27 | */ |
---|
| 28 | public interface Storage { |
---|
| 29 | /** |
---|
| 30 | * Returns an <code>InputStream</code> that can be used to read the stored |
---|
| 31 | * data. The input stream should be closed by the caller when it is no |
---|
| 32 | * longer needed. |
---|
| 33 | * <p> |
---|
| 34 | * Note: The stream should NOT be wrapped in a |
---|
| 35 | * <code>BufferedInputStream</code> by the caller. If the implementing |
---|
| 36 | * <code>Storage</code> creates a stream which would benefit from being |
---|
| 37 | * buffered it is the <code>Storage</code>'s responsibility to wrap it. |
---|
| 38 | * |
---|
| 39 | * @return an <code>InputStream</code> for reading the stored data. |
---|
| 40 | * @throws IOException |
---|
| 41 | * if an I/O error occurs. |
---|
| 42 | * @throws IllegalStateException |
---|
| 43 | * if this <code>Storage</code> instance has been deleted. |
---|
| 44 | */ |
---|
| 45 | InputStream getInputStream() throws IOException; |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * Deletes the data held by this <code>Storage</code> as soon as possible. |
---|
| 49 | * Deleting an already deleted <code>Storage</code> has no effect. |
---|
| 50 | */ |
---|
| 51 | void delete(); |
---|
| 52 | |
---|
| 53 | } |
---|