1 /* 2 * The contents of this file are subject to the terms 3 * of the Common Development and Distribution License 4 * (the "License"). You may not use this file except 5 * in compliance with the License. 6 * 7 * You can obtain a copy of the license at 8 * glassfish/bootstrap/legal/CDDLv1.0.txt or 9 * https://glassfish.dev.java.net/public/CDDLv1.0.html. 10 * See the License for the specific language governing 11 * permissions and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL 14 * HEADER in each file and include the License file at 15 * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable, 16 * add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your 18 * own identifying information: Portions Copyright [yyyy] 19 * [name of copyright owner] 20 */ 21 22 /* 23 * @(#)SharedInputStream.java 1.4 05/08/29 24 * 25 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. 26 */ 27 28 package javax.mail.internet; 29 30 import java.io.*; 31 32 /** 33 * An InputStream that is backed by data that can be shared by multiple 34 * readers may implement this interface. This allows users of such an 35 * InputStream to determine the current position in the InputStream, and 36 * to create new InputStreams representing a subset of the data in the 37 * original InputStream. The new InputStream will access the same 38 * underlying data as the original, without copying the data. <p> 39 * 40 * Note that implementations of this interface must ensure that the 41 * <code>close</code> method does not close any underlying stream 42 * that might be shared by multiple instances of <code>SharedInputStream</code> 43 * until all shared instances have been closed. 44 * 45 * @version 1.4, 05/08/29 46 * @author Bill Shannon 47 * @since JavaMail 1.2 48 */ 49 50 public interface SharedInputStream { 51 /** 52 * Return the current position in the InputStream, as an 53 * offset from the beginning of the InputStream. 54 * 55 * @return the current position 56 */ 57 public long getPosition(); 58 59 /** 60 * Return a new InputStream representing a subset of the data 61 * from this InputStream, starting at <code>start</code> (inclusive) 62 * up to <code>end</code> (exclusive). <code>start</code> must be 63 * non-negative. If <code>end</code> is -1, the new stream ends 64 * at the same place as this stream. The returned InputStream 65 * will also implement the SharedInputStream interface. 66 * 67 * @param start the starting position 68 * @param end the ending position + 1 69 * @return the new stream 70 */ 71 public InputStream newStream(long start, long end); 72 } 73