gpt4 book ai didi

org.apache.catalina.tribes.io.XByteBuffer.setLength()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 16:29:40 26 4
gpt4 key购买 nike

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

XByteBuffer.setLength介绍

暂无

代码示例

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Extracts the message bytes from a package.
 * If no package exists, a IllegalStateException will be thrown.
 * @param clearFromBuffer - if true, the package will be removed from the byte buffer
 * @return - returns the actual message bytes (header, compress,size and footer not included).
 */
public XByteBuffer extractDataPackage(boolean clearFromBuffer) {
  int psize = countPackages(true);
  if (psize == 0) {
    throw new java.lang.IllegalStateException("No package exists in XByteBuffer");
  }
  int size = toInt(buf, START_DATA.length);
  XByteBuffer xbuf = BufferPool.getBufferPool().getBuffer(size,false);
  xbuf.setLength(size);
  System.arraycopy(buf, START_DATA.length + 4, xbuf.getBytesDirect(), 0, size);
  if (clearFromBuffer) {
    int totalsize = START_DATA.length + 4 + size + END_DATA.length;
    bufSize = bufSize - totalsize;
    System.arraycopy(buf, totalsize, buf, 0, bufSize);
  }
  return xbuf;
}

代码示例来源:origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

/**
 * Extracts the message bytes from a package.
 * If no package exists, a IllegalStateException will be thrown.
 * @param clearFromBuffer - if true, the package will be removed from the byte buffer
 * @return - returns the actual message bytes (header, compress,size and footer not included).
 */
public XByteBuffer extractDataPackage(boolean clearFromBuffer) {
  int psize = countPackages(true);
  if (psize == 0) {
    throw new java.lang.IllegalStateException("No package exists in XByteBuffer");
  }
  int size = toInt(buf, START_DATA.length);
  XByteBuffer xbuf = BufferPool.getBufferPool().getBuffer(size,false);
  xbuf.setLength(size);
  System.arraycopy(buf, START_DATA.length + 4, xbuf.getBytesDirect(), 0, size);
  if (clearFromBuffer) {
    int totalsize = START_DATA.length + 4 + size + END_DATA.length;
    bufSize = bufSize - totalsize;
    System.arraycopy(buf, totalsize, buf, 0, bufSize);
  }
  return xbuf;
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/tribes

/**
 * Extracts the message bytes from a package.
 * If no package exists, a IllegalStateException will be thrown.
 * @param clearFromBuffer - if true, the package will be removed from the byte buffer
 * @return - returns the actual message bytes (header, compress,size and footer not included).
 */
public XByteBuffer extractDataPackage(boolean clearFromBuffer) {
  int psize = countPackages(true);
  if (psize == 0) {
    throw new java.lang.IllegalStateException("No package exists in XByteBuffer");
  }
  int size = toInt(buf, START_DATA.length);
  XByteBuffer xbuf = BufferPool.getBufferPool().getBuffer(size,false);
  xbuf.setLength(size);
  System.arraycopy(buf, START_DATA.length + 4, xbuf.getBytesDirect(), 0, size);
  if (clearFromBuffer) {
    int totalsize = START_DATA.length + 4 + size + END_DATA.length;
    bufSize = bufSize - totalsize;
    System.arraycopy(buf, totalsize, buf, 0, bufSize);
  }
  return xbuf;
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

/**
 * Extracts the message bytes from a package.
 * If no package exists, a IllegalStateException will be thrown.
 * @param clearFromBuffer - if true, the package will be removed from the byte buffer
 * @return - returns the actual message bytes (header, compress,size and footer not included).
 */
public XByteBuffer extractDataPackage(boolean clearFromBuffer) {
  int psize = countPackages(true);
  if (psize == 0) {
    throw new java.lang.IllegalStateException(sm.getString("xByteBuffer.no.package"));
  }
  int size = toInt(buf, START_DATA.length);
  XByteBuffer xbuf = BufferPool.getBufferPool().getBuffer(size,false);
  xbuf.setLength(size);
  System.arraycopy(buf, START_DATA.length + 4, xbuf.getBytesDirect(), 0, size);
  if (clearFromBuffer) {
    int totalsize = START_DATA.length + 4 + size + END_DATA.length;
    bufSize = bufSize - totalsize;
    System.arraycopy(buf, totalsize, buf, 0, bufSize);
  }
  return xbuf;
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Deserializes a ChannelData object from a byte array
 * @param xbuf byte[]
 * @return ChannelData
 */
public static ChannelData getDataFromPackage(XByteBuffer xbuf)  {
  ChannelData data = new ChannelData(false);
  int offset = 0;
  data.setOptions(XByteBuffer.toInt(xbuf.getBytesDirect(),offset));
  offset += 4; //options
  data.setTimestamp(XByteBuffer.toLong(xbuf.getBytesDirect(),offset));
  offset += 8; //timestamp
  data.uniqueId = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  offset += 4; //uniqueId length
  System.arraycopy(xbuf.getBytesDirect(),offset,data.uniqueId,0,data.uniqueId.length);
  offset += data.uniqueId.length; //uniqueId data
  //byte[] addr = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  int addrlen = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //addr length
  //System.arraycopy(xbuf.getBytesDirect(),offset,addr,0,addr.length);
  data.setAddress(MemberImpl.getMember(xbuf.getBytesDirect(),offset,addrlen));
  //offset += addr.length; //addr data
  offset += addrlen;
  int xsize = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //xsize length
  System.arraycopy(xbuf.getBytesDirect(),offset,xbuf.getBytesDirect(),0,xsize);
  xbuf.setLength(xsize);
  data.message = xbuf;
  return data;
}

代码示例来源:origin: org.apache.tomcat/tomcat-tribes

/**
 * Deserializes a ChannelData object from a byte array
 * @param xbuf byte[]
 * @return ChannelData
 */
public static ChannelData getDataFromPackage(XByteBuffer xbuf)  {
  ChannelData data = new ChannelData(false);
  int offset = 0;
  data.setOptions(XByteBuffer.toInt(xbuf.getBytesDirect(),offset));
  offset += 4; //options
  data.setTimestamp(XByteBuffer.toLong(xbuf.getBytesDirect(),offset));
  offset += 8; //timestamp
  data.uniqueId = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  offset += 4; //uniqueId length
  System.arraycopy(xbuf.getBytesDirect(),offset,data.uniqueId,0,data.uniqueId.length);
  offset += data.uniqueId.length; //uniqueId data
  //byte[] addr = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  int addrlen = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //addr length
  //System.arraycopy(xbuf.getBytesDirect(),offset,addr,0,addr.length);
  data.setAddress(MemberImpl.getMember(xbuf.getBytesDirect(),offset,addrlen));
  //offset += addr.length; //addr data
  offset += addrlen;
  int xsize = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //xsize length
  System.arraycopy(xbuf.getBytesDirect(),offset,xbuf.getBytesDirect(),0,xsize);
  xbuf.setLength(xsize);
  data.message = xbuf;
  return data;
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/tribes

/**
 * Deserializes a ChannelData object from a byte array
 * @param xbuf byte[]
 * @return ChannelData
 */
public static ChannelData getDataFromPackage(XByteBuffer xbuf)  {
  ChannelData data = new ChannelData(false);
  int offset = 0;
  data.setOptions(XByteBuffer.toInt(xbuf.getBytesDirect(),offset));
  offset += 4; //options
  data.setTimestamp(XByteBuffer.toLong(xbuf.getBytesDirect(),offset));
  offset += 8; //timestamp
  data.uniqueId = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  offset += 4; //uniqueId length
  System.arraycopy(xbuf.getBytesDirect(),offset,data.uniqueId,0,data.uniqueId.length);
  offset += data.uniqueId.length; //uniqueId data
  //byte[] addr = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  int addrlen = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //addr length
  //System.arraycopy(xbuf.getBytesDirect(),offset,addr,0,addr.length);
  data.setAddress(MemberImpl.getMember(xbuf.getBytesDirect(),offset,addrlen));
  //offset += addr.length; //addr data
  offset += addrlen;
  int xsize = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //xsize length
  System.arraycopy(xbuf.getBytesDirect(),offset,xbuf.getBytesDirect(),0,xsize);
  xbuf.setLength(xsize);
  data.message = xbuf;
  return data;
}

代码示例来源:origin: org.apache.catalina.springsource/com.springsource.org.apache.catalina.tribes.springsource

/**
 * Deserializes a ChannelData object from a byte array
 * @param b byte[]
 * @return ChannelData
 */
public static ChannelData getDataFromPackage(XByteBuffer xbuf)  {
  ChannelData data = new ChannelData(false);
  int offset = 0;
  data.setOptions(XByteBuffer.toInt(xbuf.getBytesDirect(),offset));
  offset += 4; //options
  data.setTimestamp(XByteBuffer.toLong(xbuf.getBytesDirect(),offset));
  offset += 8; //timestamp
  data.uniqueId = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  offset += 4; //uniqueId length
  System.arraycopy(xbuf.getBytesDirect(),offset,data.uniqueId,0,data.uniqueId.length);
  offset += data.uniqueId.length; //uniqueId data
  //byte[] addr = new byte[XByteBuffer.toInt(xbuf.getBytesDirect(),offset)];
  int addrlen = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //addr length
  //System.arraycopy(xbuf.getBytesDirect(),offset,addr,0,addr.length);
  data.setAddress(MemberImpl.getMember(xbuf.getBytesDirect(),offset,addrlen));
  //offset += addr.length; //addr data
  offset += addrlen;
  int xsize = XByteBuffer.toInt(xbuf.getBytesDirect(),offset);
  offset += 4; //xsize length
  System.arraycopy(xbuf.getBytesDirect(),offset,xbuf.getBytesDirect(),0,xsize);
  xbuf.setLength(xsize);
  data.message = xbuf;
  return data;
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com