org.apache.sshd.common.util.buffer.Buffer.available()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.apache.sshd.common.util.buffer.Buffer.available()方法的一些代码示例,展示了Buffer.available()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.available()方法的具体详情如下:
包路径:org.apache.sshd.common.util.buffer.Buffer
类名称:Buffer
方法名:available

Buffer.available介绍

暂无

代码示例

代码示例来源:origin: org.apache.sshd/sshd-core

protected int readRawInput() throws IOException {
  if (buffer.available() > 0) {
    return buffer.getUByte();
  } else {
    return this.in.read();
  }
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

/**
 * Retrieves the end-of-file indicator for {@code SSH_FXP_DATA} responses, provided
 * the version is at least 6, and the buffer has enough available data
 *
 * @param buffer  The {@link Buffer} to retrieve the data from
 * @param version The SFTP version being used
 * @return The indicator value - {@code null} if none retrieved
 * @see <A HREF="https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.3">SFTP v6 - section 9.3</A>
 */
public static Boolean getEndOfFileIndicatorValue(Buffer buffer, int version) {
  return (version <  SftpConstants.SFTP_V6) || (buffer.available() < 1) ? null : buffer.getBoolean();
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

protected int readRawInput() throws IOException {
  if (buffer.available() > 0) {
    return buffer.getUByte();
  } else {
    return this.in.read();
  }
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

/**
 * Retrieves the end-of-list indicator for {@code SSH_FXP_NAME} responses, provided
 * the version is at least 6, and the buffer has enough available data
 *
 * @param buffer  The {@link Buffer} to retrieve the data from
 * @param version The SFTP version being used
 * @return The indicator value - {@code null} if none retrieved
 * @see <A HREF="https://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.4">SFTP v6 - section 9.4</A>
 * @see #indicateEndOfNamesList(Buffer, int, PropertyResolver, boolean)
 */
public static Boolean getEndOfListIndicatorValue(Buffer buffer, int version) {
  return (version <  SftpConstants.SFTP_V6) || (buffer.available() < 1) ? null : buffer.getBoolean();
}

代码示例来源:origin: org.apache.sshd/sshd-common

public void ensureAvailable(int reqLen) throws BufferException {
  int availLen = available();
  if (availLen < reqLen) {
    throw new BufferException("Underflow: requested=" + reqLen + ", available=" + availLen);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
  protected void reply(Buffer buf) throws IOException {
    out.write(buf.array(), buf.rpos(), buf.available());
    out.flush();
  }
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
  protected void reply(Buffer buf) throws IOException {
    out.write(buf.array(), buf.rpos(), buf.available());
    out.flush();
  }
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
  public void uncompress(Buffer from, Buffer to) throws IOException {
    decompresser.setInput(from.array(), from.rpos(), from.available());
    try {
      for (int len = decompresser.inflate(tmpbuf); len > 0; len = decompresser.inflate(tmpbuf)) {
        to.putRawBytes(tmpbuf, 0, len);
      }
    } catch (DataFormatException e) {
      throw new IOException("Error decompressing data", e);
    }
  }
}

代码示例来源:origin: org.apache.sshd/sshd-common

public byte[] getCompactData() {
  int l = available();
  if (l > 0) {
    byte[] b = new byte[l];
    System.arraycopy(array(), rpos(), b, 0, l);
    return b;
  } else {
    return GenericUtils.EMPTY_BYTE_ARRAY;
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected void onMessage(Buffer buffer) throws IOException {
  OutputStream invertedIn = channel.getInvertedIn();
  invertedIn.write(buffer.array(), buffer.rpos(), buffer.available());
  invertedIn.flush();
}

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
public void messageReceived(IoSession session, Readable message) throws Exception {
  ChannelForwardedX11 channel = (ChannelForwardedX11) session.getAttribute(ChannelForwardedX11.class);
  Buffer buffer = new ByteArrayBuffer(message.available() + Long.SIZE, false);
  buffer.putBuffer(message);
  if (log.isTraceEnabled()) {
    log.trace("messageReceived({}) channel={}, len={}", session, channel, buffer.available());
  }
  OutputStream outputStream = channel.getInvertedIn();
  outputStream.write(buffer.array(), buffer.rpos(), buffer.available());
  outputStream.flush();
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
public void messageReceived(IoSession session, Readable message) throws Exception {
  ChannelForwardedX11 channel = (ChannelForwardedX11) session.getAttribute(ChannelForwardedX11.class);
  Buffer buffer = new ByteArrayBuffer(message.available() + Long.SIZE, false);
  buffer.putBuffer(message);
  if (log.isTraceEnabled()) {
    log.trace("messageReceived({}) channel={}, len={}", session, channel, buffer.available());
  }
  OutputStream outputStream = channel.getInvertedIn();
  outputStream.write(buffer.array(), buffer.rpos(), buffer.available());
  outputStream.flush();
}

代码示例来源:origin: org.apache.sshd/sshd-common

@Override
public void compress(Buffer buffer) throws IOException {
  compresser.setInput(buffer.array(), buffer.rpos(), buffer.available());
  buffer.wpos(buffer.rpos());
  for (int len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH);
      len > 0;
      len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH)) {
    buffer.putRawBytes(tmpbuf, 0, len);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
public void compress(Buffer buffer) throws IOException {
  compresser.setInput(buffer.array(), buffer.rpos(), buffer.available());
  buffer.wpos(buffer.rpos());
  for (int len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH);
      len > 0;
      len = compresser.deflate(tmpbuf, 0, tmpbuf.length, Deflater.SYNC_FLUSH)) {
    buffer.putRawBytes(tmpbuf, 0, len);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@SuppressWarnings("synthetic-access")
@Override
protected void reply(Buffer buf) throws IOException {
  int result = Socket.send(socket, buf.array(), buf.rpos(), buf.available());
  if (result < Status.APR_SUCCESS) {
    throwException(result);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

@SuppressWarnings("synthetic-access")
@Override
protected void reply(Buffer buf) throws IOException {
  int result = Socket.send(socket, buf.array(), buf.rpos(), buf.available());
  if (result < Status.APR_SUCCESS) {
    throwException(result);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
protected void preClose() {
  synchronized (buffer) {
    if (buffer.available() == 0) {
      if (pending != null) {
        pending.setValue(new SshException("Closed"));
      }
    }
  }
  super.preClose();
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

@Override
protected void preClose() {
  synchronized (buffer) {
    if (buffer.available() == 0) {
      if (pending != null) {
        pending.setValue(new SshException("Closed"));
      }
    }
  }
  super.preClose();
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected Buffer prepare(Buffer buf) {
  int len = buf.available();
  int rpos = buf.rpos();
  int wpos = buf.wpos();
  buf.rpos(rpos - 4);
  buf.wpos(rpos - 4);
  buf.putInt(len);
  buf.wpos(wpos);
  return buf;
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void doWrite(Buffer buffer, int id) throws IOException {
  String handle = buffer.getString();
  long offset = buffer.getLong();
  int length = buffer.getInt();
  try {
    doWrite(id, handle, offset, length, buffer.array(), buffer.rpos(), buffer.available());
  } catch (IOException | RuntimeException e) {
    sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_WRITE, handle, offset, length);
    return;
  }
  sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

相关文章