com.devexperts.io
Class BufferedInputPart

java.lang.Object
  extended by java.io.InputStream
      extended by com.devexperts.io.BufferedInput
          extended by com.devexperts.io.BufferedInputPart
All Implemented Interfaces:
Closeable, DataInput, ObjectInput

public final class BufferedInputPart
extends BufferedInput

A size-delimited part of BufferedInput for parsing of size-tagged packets.


Field Summary
 
Fields inherited from class com.devexperts.io.BufferedInput
buffer, EMPTY_BYTE_ARRAY, limit, markLimit, markPosition, position, totalPositionBase
 
Constructor Summary
BufferedInputPart()
           
BufferedInputPart(BufferedInput in, long length)
           
 
Method Summary
 int available()
           
 void close()
           
 int read(byte[] b, int off, int len)
           
protected  int readData()
          This method is invoked when input methods need more bytes to read data.
 void resetInput()
           
 void rewind(long n)
          Rewinds specified number of bytes.
 void setInput(BufferedInput in, long length)
           
 long skip(long n)
           
 
Methods inherited from class com.devexperts.io.BufferedInput
checkEOB, checkRewind, mark, mark, markSupported, needData, read, read, readBoolean, readByte, readByteArray, readChar, readCompactInt, readCompactLong, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readObject, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTFChar, readUTFString, reset, seek, skipBytes, throwEOFException, totalPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedInputPart

public BufferedInputPart()

BufferedInputPart

public BufferedInputPart(BufferedInput in,
                         long length)
Method Detail

setInput

public void setInput(BufferedInput in,
                     long length)

resetInput

public void resetInput()

close

public void close()
Specified by:
close in interface Closeable
Specified by:
close in interface ObjectInput
Overrides:
close in class InputStream

available

public int available()
              throws IOException
Specified by:
available in interface ObjectInput
Overrides:
available in class BufferedInput
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Specified by:
read in interface ObjectInput
Overrides:
read in class BufferedInput
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Specified by:
skip in interface ObjectInput
Overrides:
skip in class BufferedInput
Throws:
IOException

rewind

public void rewind(long n)
Description copied from class: BufferedInput
Rewinds specified number of bytes. The input cannot be rewound past the marked position.

Specified by:
rewind in class BufferedInput
Parameters:
n - the number of bytes to rewind

readData

protected int readData()
                throws IOException
Description copied from class: BufferedInput
This method is invoked when input methods need more bytes to read data. This method shall make an attempt to read some bytes into the buffer. This method returns number of bytes actually read or value -1 if no bytes can be read because the end of the stream has been reached. This method may block if needed. This method is allowed to update buffer, position, limit and totalPositionBase fields as needed.

This method shall never throw an EOFException.

Specified by:
readData in class BufferedInput
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached
Throws:
IOException - if an I/O error occurs


Copyright © 2013 Devexperts. All Rights Reserved.