}
//wrap the input stream by a bounded stream, subtract buf.length from the
//length because the size itself is included in the length
int documentLength = ByteBuffer.wrap(buf).order(ByteOrder.LITTLE_ENDIAN).getInt();
InputStream in = new BoundedInputStream(_rawInputStream, documentLength - buf.length);
//buffer if the raw input stream is not already buffered
if (!(_rawInputStream instanceof BufferedInputStream)) {
in = new StaticBufferedInputStream(in);
}