Class ChannelIO

java.lang.Object
jp.cssj.driver.ctip.common.ChannelIO

public final class ChannelIO extends Object
SocketChannelから各種データを取得します。 それぞれのメソッドは非ブロッキングI/Oに対して動作しますが、データの取得が完了するまでブロックします。
  • Constructor Details

  • Method Details

    • getChannel

      public ByteChannel getChannel()
    • getSelectable

      public SelectableChannel getSelectable()
    • close

      public void close() throws IOException
      Throws:
      IOException
    • readByte

      public byte readByte(ByteBuffer destByte) throws IOException
      1バイト整数を読み込みます。
      Parameters:
      destByte -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readShort

      public short readShort(ByteBuffer destShort) throws IOException
      2バイト整数を読み込みます。
      Parameters:
      destShort -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readInt

      public int readInt(ByteBuffer destInt) throws IOException
      4バイト整数を読み込みます。
      Parameters:
      destInt -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readLong

      public long readLong(ByteBuffer destLong) throws IOException
      8バイト整数を読み込みます。
      Parameters:
      destLong -
      Returns:
      読み込んだ値。
      Throws:
      IOException
    • readString

      public String readString(ByteBuffer destShort, String encoding) throws IOException
      文字列を読み込みます。 文字列は2バイトの文字列長(バイト数)に続く文字列本体のバイト列で構成されます。 バイト列は指定したエンコーディングで文字列に変換します。
      Parameters:
      destShort -
      encoding -
      Returns:
      読み込んだ文字列。
      Throws:
      IOException
    • readBytes

      public byte[] readBytes(int len) throws IOException
      指定された長さだけバイト列を読み込みます。
      Parameters:
      len -
      Returns:
      読み込んだデータ。
      Throws:
      IOException
    • rwselect

      public SelectionKey rwselect() throws IOException
      読み込みまたは書き込みが可能になるまで待ちます。
      Returns:
      チャンネルの状態のキー。
      Throws:
      IOException
    • readAll

      public void readAll(ByteBuffer dest) throws IOException
      バッファがいっぱいになるまでデータを読み込みます。
      Parameters:
      dest -
      Throws:
      IOException
    • writeAll

      public void writeAll(ByteBuffer src) throws IOException
      バッファが空になるまでデータを書き込みます。
      Parameters:
      src -
      Throws:
      IOException
    • toBytes

      public static byte[] toBytes(String str, String encoding) throws IOException
      文字列をバイト列に変換します。 null文字列は空文字列として変換します。
      Parameters:
      str -
      encoding -
      Returns:
      変換後のバイト列。
      Throws:
      IOException