01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common Development
08: * and Distribution License("CDDL") (collectively, the "License"). You
09: * may not use this file except in compliance with the License. You can obtain
10: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12: * language governing permissions and limitations under the License.
13: *
14: * When distributing the software, include this License Header Notice in each
15: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
16: * Sun designates this particular file as subject to the "Classpath" exception
17: * as provided by Sun in the GPL Version 2 section of the License file that
18: * accompanied this code. If applicable, add the following below the License
19: * Header, with the fields enclosed by brackets [] replaced by your own
20: * identifying information: "Portions Copyrighted [year]
21: * [name of copyright owner]"
22: *
23: * Contributor(s):
24: *
25: * If you wish your version of this file to be governed by only the CDDL or
26: * only the GPL Version 2, indicate your decision by adding "[Contributor]
27: * elects to include this software in this distribution under the [CDDL or GPL
28: * Version 2] license." If you don't indicate a single choice of license, a
29: * recipient has the option to distribute your version of this file under
30: * either the CDDL, the GPL Version 2 or to extend the choice of license to
31: * its licensees as provided above. However, if you add GPL Version 2 code
32: * and therefore, elected the GPL Version 2 license, then the option applies
33: * only if the new code is made subject to such option by the copyright
34: * holder.
35: */
36:
37: /*
38: * @(#)SharedInputStream.java 1.5 07/05/04
39: */
40:
41: package javax.mail.internet;
42:
43: import java.io.*;
44:
45: /**
46: * An InputStream that is backed by data that can be shared by multiple
47: * readers may implement this interface. This allows users of such an
48: * InputStream to determine the current position in the InputStream, and
49: * to create new InputStreams representing a subset of the data in the
50: * original InputStream. The new InputStream will access the same
51: * underlying data as the original, without copying the data. <p>
52: *
53: * Note that implementations of this interface must ensure that the
54: * <code>close</code> method does not close any underlying stream
55: * that might be shared by multiple instances of <code>SharedInputStream</code>
56: * until all shared instances have been closed.
57: *
58: * @version 1.5, 07/05/04
59: * @author Bill Shannon
60: * @since JavaMail 1.2
61: */
62:
63: public interface SharedInputStream {
64: /**
65: * Return the current position in the InputStream, as an
66: * offset from the beginning of the InputStream.
67: *
68: * @return the current position
69: */
70: public long getPosition();
71:
72: /**
73: * Return a new InputStream representing a subset of the data
74: * from this InputStream, starting at <code>start</code> (inclusive)
75: * up to <code>end</code> (exclusive). <code>start</code> must be
76: * non-negative. If <code>end</code> is -1, the new stream ends
77: * at the same place as this stream. The returned InputStream
78: * will also implement the SharedInputStream interface.
79: *
80: * @param start the starting position
81: * @param end the ending position + 1
82: * @return the new stream
83: */
84: public InputStream newStream(long start, long end);
85: }
|