パッケージ org.postgresql.core

クラス VisibleBufferedInputStream

java.lang.Object
java.io.InputStream
org.postgresql.core.VisibleBufferedInputStream
すべての実装されたインタフェース:
Closeable, AutoCloseable

public class VisibleBufferedInputStream extends InputStream
A faster version of BufferedInputStream. Does no synchronisation and allows direct access to the used byte[] buffer.
  • コンストラクタの詳細

    • VisibleBufferedInputStream

      public VisibleBufferedInputStream(InputStream in, int bufferSize)
      Creates a new buffer around the given stream.
      パラメータ:
      in - The stream to buffer.
      bufferSize - The initial size of the buffer.
  • メソッドの詳細

    • read

      public int read() throws IOException
      定義:
      read クラス内 InputStream
      例外:
      IOException
    • peek

      public int peek() throws IOException
      Reads a byte from the buffer without advancing the index pointer.
      戻り値:
      byte from the buffer without advancing the index pointer
      例外:
      IOException - if something wrong happens
    • readRaw

      public byte readRaw()
      Reads byte from the buffer without any checks. This method never reads from the underlaying stream. Before calling this method the ensureBytes(int) method must have been called.
      戻り値:
      The next byte from the buffer.
      例外:
      ArrayIndexOutOfBoundsException - If ensureBytes was not called to make sure the buffer contains the byte.
    • ensureBytes

      public boolean ensureBytes(int n) throws IOException
      Ensures that the buffer contains at least n bytes. This method invalidates the buffer and index fields.
      パラメータ:
      n - The amount of bytes to ensure exists in buffer
      戻り値:
      true if required bytes are available and false if EOF
      例外:
      IOException - If reading of the wrapped stream failed.
    • ensureBytes

      public boolean ensureBytes(int n, boolean block) throws IOException
      Ensures that the buffer contains at least n bytes. This method invalidates the buffer and index fields.
      パラメータ:
      n - The amount of bytes to ensure exists in buffer
      block - whether or not to block the IO
      戻り値:
      true if required bytes are available and false if EOF or the parameter block was false and socket timeout occurred.
      例外:
      IOException - If reading of the wrapped stream failed.
    • ensureBytes

      public boolean ensureBytes(int n, boolean block, boolean viaCM) throws IOException
      Ensures that the buffer contains at least n bytes. This method invalidates the buffer and index fields.
      パラメータ:
      n - The amount of bytes to ensure exists in buffer
      block - whether or not to block the IO
      viaCM - Whether it is a CM connection
      戻り値:
      true if required bytes are available and false if EOF or the parameter block was false and socket timeout occurred.
      例外:
      IOException - If reading of the wrapped stream failed.
    • read

      public int read(byte[] to, int off, int len) throws IOException
      オーバーライド:
      read クラス内 InputStream
      例外:
      IOException
    • skip

      public long skip(long n) throws IOException
      オーバーライド:
      skip クラス内 InputStream
      例外:
      IOException
    • available

      public int available() throws IOException
      オーバーライド:
      available クラス内 InputStream
      例外:
      IOException
    • close

      public void close() throws IOException
      定義:
      close インタフェース内 AutoCloseable
      定義:
      close インタフェース内 Closeable
      オーバーライド:
      close クラス内 InputStream
      例外:
      IOException
    • getBuffer

      public byte[] getBuffer()
      Returns direct handle to the used buffer. Use the ensureBytes(int) to prefill required bytes the buffer and getIndex() to fetch the current position of the buffer.
      戻り値:
      The underlaying buffer.
    • getIndex

      public int getIndex()
      Returns the current read position in the buffer.
      戻り値:
      the current read position in the buffer.
    • scanCStringLength

      public int scanCStringLength() throws IOException
      Scans the length of the next null terminated string (C-style string) from the stream.
      戻り値:
      The length of the next null terminated string.
      例外:
      IOException - If reading of stream fails.
      EOFException - If the stream did not contain any null terminators.
    • scanCStringLength

      public int scanCStringLength(boolean viaCM) throws IOException
      Scans the length of the next null terminated string (C-style string) from the stream.
      パラメータ:
      viaCM - Whether it is a CM connection
      戻り値:
      The length of the next null terminated string.
      例外:
      IOException - If reading of stream fails.
      EOFException - If the stream did not contain any null terminators.
    • setTimeoutRequested

      public void setTimeoutRequested(boolean timeoutRequested)
    • getWrapped

      public InputStream getWrapped()
      戻り値:
      the wrapped stream