/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*
*/
/**
* The StreamBuffer class provides a space that can be written to with an
* OutputStream and read from with an InputStream. It is similar to
* PipedInput/OutputStream except that it is unsynchronized and more
* lightweight. StreamBuffers are used inside of the serialization benchmarks
* underlying stream (using ByteArrayInput/OutputStreams results in allocation
* of a new byte array with each cycle, while using PipedInput/OutputStreams
* involves threading and synchronization).
* <p>
* from a StreamBuffer effectively close the StreamBuffer output stream. These
* StreamBufferInputStream.read().
*/
public class StreamBuffer {
/**
* Output stream for writing to stream buffer.
*/
private int pos;
if (mode != WRITE_MODE)
throw new IOException();
grow();
}
if (mode != WRITE_MODE)
throw new IOException();
grow();
}
if (mode != WRITE_MODE)
throw new IOException();
}
}
/**
* Input stream for reading from stream buffer.
*/
private int pos;
if (mode == CLOSED_MODE)
throw new IOException();
}
if (mode == CLOSED_MODE)
throw new IOException();
return rlen;
}
if (mode == CLOSED_MODE)
throw new IOException();
return slen;
}
if (mode == CLOSED_MODE)
throw new IOException();
}
if (mode == CLOSED_MODE)
throw new IOException();
mode = CLOSED_MODE;
}
}
private byte[] buf;
public StreamBuffer() {
this(START_BUFSIZE);
}
}
return out;
}
return in;
}
public void reset() {
mode = WRITE_MODE;
}
private void grow() {
}
}