- public boolean startWith() {
- // TODO
- return false;
- }
-
- public boolean startWiths() {
- // TODO
- return false;
- }
-
- /**
- * The number of bytes read from the under-laying {@link InputStream}.
- *
- * @return the number of bytes
- */
- public long getBytesRead() {
- return bytesRead;
- }
-
- /**
- * Check if this stream is totally spent (no more data to read or to
- * process).
- *
- * @return TRUE if it is
- */
- public boolean eof() {
- return closed || (len < 0 && !hasMoreData());
- }
-
- @Override
- public int read() throws IOException {
- checkClose();
-
- preRead();
- if (eof) {
- return -1;
- }
-
- return buffer[pos++];
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- @Override
- public int read(byte[] b, int boff, int blen) throws IOException {
- checkClose();
-
- if (b == null) {
- throw new NullPointerException();
- } else if (boff < 0 || blen < 0 || blen > b.length - boff) {
- throw new IndexOutOfBoundsException();
- } else if (blen == 0) {
- return 0;
- }
-
- int done = 0;
- while (hasMoreData() && done < blen) {
- preRead();
- if (hasMoreData()) {
- for (int i = pos; i < blen && i < len; i++) {
- b[boff + done] = buffer[i];
- pos++;
- done++;
- }
- }
- }
-
- return done > 0 ? done : -1;
- }
-
- @Override
- public long skip(long n) throws IOException {
- // TODO Auto-generated method stub
- return super.skip(n);
- }
-
- @Override
- public int available() {
- if (closed) {
- return 0;
- }
-
- return Math.max(0, len - pos);
- }
-
- /**
- * Closes this stream and releases any system resources associated with the
- * stream.
- * <p>
- * Including the under-laying {@link InputStream}.
- * <p>
- * <b>Note:</b> if you called the {@link NextableInputStream#open()} method
- * prior to this one, it will just decrease the internal count of how many
- * open streams it held and do nothing else. The stream will actually be
- * closed when you have called {@link NextableInputStream#close()} once more
- * than {@link NextableInputStream#open()}.
- *
- * @exception IOException
- * in case of I/O error
- */
- @Override
- public synchronized void close() throws IOException {
- close(true);
- }
-
- /**
- * Closes this stream and releases any system resources associated with the
- * stream.
- * <p>
- * Including the under-laying {@link InputStream} if
- * <tt>incudingSubStream</tt> is true.
- * <p>
- * You can call this method multiple times, it will not cause an
- * {@link IOException} for subsequent calls.
- * <p>
- * <b>Note:</b> if you called the {@link NextableInputStream#open()} method
- * prior to this one, it will just decrease the internal count of how many
- * open streams it held and do nothing else. The stream will actually be
- * closed when you have called {@link NextableInputStream#close()} once more
- * than {@link NextableInputStream#open()}.
- *
- * @exception IOException
- * in case of I/O error
- */
- public synchronized void close(boolean includingSubStream)
- throws IOException {
- if (!closed) {
- if (openCounter > 0) {
- openCounter--;
- } else {
- closed = true;
- if (includingSubStream && in != null) {
- in.close();
- }
- }
- }
- }
-