1.1 --- a/emul/mini/src/main/java/java/io/FilterInputStream.java Tue Feb 26 14:55:55 2013 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,245 +0,0 @@
1.4 -/*
1.5 - * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 - *
1.8 - * This code is free software; you can redistribute it and/or modify it
1.9 - * under the terms of the GNU General Public License version 2 only, as
1.10 - * published by the Free Software Foundation. Oracle designates this
1.11 - * particular file as subject to the "Classpath" exception as provided
1.12 - * by Oracle in the LICENSE file that accompanied this code.
1.13 - *
1.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 - * version 2 for more details (a copy is included in the LICENSE file that
1.18 - * accompanied this code).
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License version
1.21 - * 2 along with this work; if not, write to the Free Software Foundation,
1.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 - *
1.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 - * or visit www.oracle.com if you need additional information or have any
1.26 - * questions.
1.27 - */
1.28 -
1.29 -package java.io;
1.30 -
1.31 -/**
1.32 - * A <code>FilterInputStream</code> contains
1.33 - * some other input stream, which it uses as
1.34 - * its basic source of data, possibly transforming
1.35 - * the data along the way or providing additional
1.36 - * functionality. The class <code>FilterInputStream</code>
1.37 - * itself simply overrides all methods of
1.38 - * <code>InputStream</code> with versions that
1.39 - * pass all requests to the contained input
1.40 - * stream. Subclasses of <code>FilterInputStream</code>
1.41 - * may further override some of these methods
1.42 - * and may also provide additional methods
1.43 - * and fields.
1.44 - *
1.45 - * @author Jonathan Payne
1.46 - * @since JDK1.0
1.47 - */
1.48 -public
1.49 -class FilterInputStream extends InputStream {
1.50 - /**
1.51 - * The input stream to be filtered.
1.52 - */
1.53 - protected volatile InputStream in;
1.54 -
1.55 - /**
1.56 - * Creates a <code>FilterInputStream</code>
1.57 - * by assigning the argument <code>in</code>
1.58 - * to the field <code>this.in</code> so as
1.59 - * to remember it for later use.
1.60 - *
1.61 - * @param in the underlying input stream, or <code>null</code> if
1.62 - * this instance is to be created without an underlying stream.
1.63 - */
1.64 - protected FilterInputStream(InputStream in) {
1.65 - this.in = in;
1.66 - }
1.67 -
1.68 - /**
1.69 - * Reads the next byte of data from this input stream. The value
1.70 - * byte is returned as an <code>int</code> in the range
1.71 - * <code>0</code> to <code>255</code>. If no byte is available
1.72 - * because the end of the stream has been reached, the value
1.73 - * <code>-1</code> is returned. This method blocks until input data
1.74 - * is available, the end of the stream is detected, or an exception
1.75 - * is thrown.
1.76 - * <p>
1.77 - * This method
1.78 - * simply performs <code>in.read()</code> and returns the result.
1.79 - *
1.80 - * @return the next byte of data, or <code>-1</code> if the end of the
1.81 - * stream is reached.
1.82 - * @exception IOException if an I/O error occurs.
1.83 - * @see java.io.FilterInputStream#in
1.84 - */
1.85 - public int read() throws IOException {
1.86 - return in.read();
1.87 - }
1.88 -
1.89 - /**
1.90 - * Reads up to <code>byte.length</code> bytes of data from this
1.91 - * input stream into an array of bytes. This method blocks until some
1.92 - * input is available.
1.93 - * <p>
1.94 - * This method simply performs the call
1.95 - * <code>read(b, 0, b.length)</code> and returns
1.96 - * the result. It is important that it does
1.97 - * <i>not</i> do <code>in.read(b)</code> instead;
1.98 - * certain subclasses of <code>FilterInputStream</code>
1.99 - * depend on the implementation strategy actually
1.100 - * used.
1.101 - *
1.102 - * @param b the buffer into which the data is read.
1.103 - * @return the total number of bytes read into the buffer, or
1.104 - * <code>-1</code> if there is no more data because the end of
1.105 - * the stream has been reached.
1.106 - * @exception IOException if an I/O error occurs.
1.107 - * @see java.io.FilterInputStream#read(byte[], int, int)
1.108 - */
1.109 - public int read(byte b[]) throws IOException {
1.110 - return read(b, 0, b.length);
1.111 - }
1.112 -
1.113 - /**
1.114 - * Reads up to <code>len</code> bytes of data from this input stream
1.115 - * into an array of bytes. If <code>len</code> is not zero, the method
1.116 - * blocks until some input is available; otherwise, no
1.117 - * bytes are read and <code>0</code> is returned.
1.118 - * <p>
1.119 - * This method simply performs <code>in.read(b, off, len)</code>
1.120 - * and returns the result.
1.121 - *
1.122 - * @param b the buffer into which the data is read.
1.123 - * @param off the start offset in the destination array <code>b</code>
1.124 - * @param len the maximum number of bytes read.
1.125 - * @return the total number of bytes read into the buffer, or
1.126 - * <code>-1</code> if there is no more data because the end of
1.127 - * the stream has been reached.
1.128 - * @exception NullPointerException If <code>b</code> is <code>null</code>.
1.129 - * @exception IndexOutOfBoundsException If <code>off</code> is negative,
1.130 - * <code>len</code> is negative, or <code>len</code> is greater than
1.131 - * <code>b.length - off</code>
1.132 - * @exception IOException if an I/O error occurs.
1.133 - * @see java.io.FilterInputStream#in
1.134 - */
1.135 - public int read(byte b[], int off, int len) throws IOException {
1.136 - return in.read(b, off, len);
1.137 - }
1.138 -
1.139 - /**
1.140 - * Skips over and discards <code>n</code> bytes of data from the
1.141 - * input stream. The <code>skip</code> method may, for a variety of
1.142 - * reasons, end up skipping over some smaller number of bytes,
1.143 - * possibly <code>0</code>. The actual number of bytes skipped is
1.144 - * returned.
1.145 - * <p>
1.146 - * This method simply performs <code>in.skip(n)</code>.
1.147 - *
1.148 - * @param n the number of bytes to be skipped.
1.149 - * @return the actual number of bytes skipped.
1.150 - * @exception IOException if the stream does not support seek,
1.151 - * or if some other I/O error occurs.
1.152 - */
1.153 - public long skip(long n) throws IOException {
1.154 - return in.skip(n);
1.155 - }
1.156 -
1.157 - /**
1.158 - * Returns an estimate of the number of bytes that can be read (or
1.159 - * skipped over) from this input stream without blocking by the next
1.160 - * caller of a method for this input stream. The next caller might be
1.161 - * the same thread or another thread. A single read or skip of this
1.162 - * many bytes will not block, but may read or skip fewer bytes.
1.163 - * <p>
1.164 - * This method returns the result of {@link #in in}.available().
1.165 - *
1.166 - * @return an estimate of the number of bytes that can be read (or skipped
1.167 - * over) from this input stream without blocking.
1.168 - * @exception IOException if an I/O error occurs.
1.169 - */
1.170 - public int available() throws IOException {
1.171 - return in.available();
1.172 - }
1.173 -
1.174 - /**
1.175 - * Closes this input stream and releases any system resources
1.176 - * associated with the stream.
1.177 - * This
1.178 - * method simply performs <code>in.close()</code>.
1.179 - *
1.180 - * @exception IOException if an I/O error occurs.
1.181 - * @see java.io.FilterInputStream#in
1.182 - */
1.183 - public void close() throws IOException {
1.184 - in.close();
1.185 - }
1.186 -
1.187 - /**
1.188 - * Marks the current position in this input stream. A subsequent
1.189 - * call to the <code>reset</code> method repositions this stream at
1.190 - * the last marked position so that subsequent reads re-read the same bytes.
1.191 - * <p>
1.192 - * The <code>readlimit</code> argument tells this input stream to
1.193 - * allow that many bytes to be read before the mark position gets
1.194 - * invalidated.
1.195 - * <p>
1.196 - * This method simply performs <code>in.mark(readlimit)</code>.
1.197 - *
1.198 - * @param readlimit the maximum limit of bytes that can be read before
1.199 - * the mark position becomes invalid.
1.200 - * @see java.io.FilterInputStream#in
1.201 - * @see java.io.FilterInputStream#reset()
1.202 - */
1.203 - public synchronized void mark(int readlimit) {
1.204 - in.mark(readlimit);
1.205 - }
1.206 -
1.207 - /**
1.208 - * Repositions this stream to the position at the time the
1.209 - * <code>mark</code> method was last called on this input stream.
1.210 - * <p>
1.211 - * This method
1.212 - * simply performs <code>in.reset()</code>.
1.213 - * <p>
1.214 - * Stream marks are intended to be used in
1.215 - * situations where you need to read ahead a little to see what's in
1.216 - * the stream. Often this is most easily done by invoking some
1.217 - * general parser. If the stream is of the type handled by the
1.218 - * parse, it just chugs along happily. If the stream is not of
1.219 - * that type, the parser should toss an exception when it fails.
1.220 - * If this happens within readlimit bytes, it allows the outer
1.221 - * code to reset the stream and try another parser.
1.222 - *
1.223 - * @exception IOException if the stream has not been marked or if the
1.224 - * mark has been invalidated.
1.225 - * @see java.io.FilterInputStream#in
1.226 - * @see java.io.FilterInputStream#mark(int)
1.227 - */
1.228 - public synchronized void reset() throws IOException {
1.229 - in.reset();
1.230 - }
1.231 -
1.232 - /**
1.233 - * Tests if this input stream supports the <code>mark</code>
1.234 - * and <code>reset</code> methods.
1.235 - * This method
1.236 - * simply performs <code>in.markSupported()</code>.
1.237 - *
1.238 - * @return <code>true</code> if this stream type supports the
1.239 - * <code>mark</code> and <code>reset</code> method;
1.240 - * <code>false</code> otherwise.
1.241 - * @see java.io.FilterInputStream#in
1.242 - * @see java.io.InputStream#mark(int)
1.243 - * @see java.io.InputStream#reset()
1.244 - */
1.245 - public boolean markSupported() {
1.246 - return in.markSupported();
1.247 - }
1.248 -}