gpt4 book ai didi

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

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

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

XByteBuffer.firstIndexOf介绍

[英]Similar to a String.IndexOf, but uses pure bytes
[中]类似于字符串。IndexOf,但使用纯字节

代码示例

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

int index = XByteBuffer.firstIndexOf(buf,start,START_DATA);
if ( (pos + END_DATA.length) > bufSize) break;
int newpos = firstIndexOf(buf, pos, END_DATA);

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

int index = XByteBuffer.firstIndexOf(buf,start,START_DATA);
if ( (pos + END_DATA.length) > bufSize) break;
int newpos = firstIndexOf(buf, pos, END_DATA);

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

int index = XByteBuffer.firstIndexOf(buf,start,START_DATA);
if ( (pos + END_DATA.length) > bufSize) break;
int newpos = firstIndexOf(buf, pos, END_DATA);

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

int index = XByteBuffer.firstIndexOf(buf,start,START_DATA);
if ( (pos + END_DATA.length) > bufSize) break;
int newpos = firstIndexOf(buf, pos, END_DATA);

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

public boolean append(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
    ((off + len) > b.length) || ((off + len) < 0))  {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return false;
  }
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  System.arraycopy(b, off, buf, bufSize, len);
  bufSize = newcount;
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error("Discarded the package, invalid header");
      return false;
    }
  }
  return true;
}

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

public boolean append(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
    ((off + len) > b.length) || ((off + len) < 0))  {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return false;
  }
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  System.arraycopy(b, off, buf, bufSize, len);
  bufSize = newcount;
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error("Discarded the package, invalid header");
      return false;
    }
  }
  return true;
}

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

public boolean append(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
    ((off + len) > b.length) || ((off + len) < 0))  {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return false;
  }
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  System.arraycopy(b, off, buf, bufSize, len);
  bufSize = newcount;
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error("Discarded the package, invalid header");
      return false;
    }
  }
  return true;
}

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

/**
 * Appends the data to the buffer. If the data is incorrectly formatted, ie, the data should always start with the
 * header, false will be returned and the data will be discarded.
 * @param b - bytes to be appended
 * @param len - the number of bytes to append.
 * @return true if the data was appended correctly. Returns false if the package is incorrect, ie missing header or something, or the length of data is 0
 */
public boolean append(ByteBuffer b, int len) {
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  b.get(buf,bufSize,len);
  
  bufSize = newcount;
  
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error("Discarded the package, invalid header");
      return false;
    }
  }
  return true;
}

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

/**
 * Appends the data to the buffer. If the data is incorrectly formatted, ie, the data should always start with the
 * header, false will be returned and the data will be discarded.
 * @param b - bytes to be appended
 * @param len - the number of bytes to append.
 * @return true if the data was appended correctly. Returns false if the package is incorrect, ie missing header or something, or the length of data is 0
 */
public boolean append(ByteBuffer b, int len) {
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  b.get(buf,bufSize,len);
  bufSize = newcount;
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error("Discarded the package, invalid header");
      return false;
    }
  }
  return true;
}

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

/**
 * Appends the data to the buffer. If the data is incorrectly formatted, ie, the data should always start with the
 * header, false will be returned and the data will be discarded.
 * @param b - bytes to be appended
 * @param off - the offset to extract data from
 * @param len - the number of bytes to append.
 * @return true if the data was appended correctly. Returns false if the package is incorrect, ie missing header or something, or the length of data is 0
 */
public boolean append(ByteBuffer b, int len) {
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  b.get(buf,bufSize,len);
  
  bufSize = newcount;
  
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error("Discarded the package, invalid header");
      return false;
    }
  }
  return true;
}

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

public boolean append(byte[] b, int off, int len) {
  if ((off < 0) || (off > b.length) || (len < 0) ||
    ((off + len) > b.length) || ((off + len) < 0))  {
    throw new IndexOutOfBoundsException();
  } else if (len == 0) {
    return false;
  }
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  System.arraycopy(b, off, buf, bufSize, len);
  bufSize = newcount;
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error(sm.getString("xByteBuffer.discarded.invalidHeader"));
      return false;
    }
  }
  return true;
}

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

/**
 * Appends the data to the buffer. If the data is incorrectly formatted, ie, the data should always start with the
 * header, false will be returned and the data will be discarded.
 * @param b - bytes to be appended
 * @param len - the number of bytes to append.
 * @return true if the data was appended correctly. Returns false if the package is incorrect, ie missing header or something, or the length of data is 0
 */
public boolean append(ByteBuffer b, int len) {
  int newcount = bufSize + len;
  if (newcount > buf.length) {
    expand(newcount);
  }
  b.get(buf,bufSize,len);
  bufSize = newcount;
  if ( discard ) {
    if (bufSize > START_DATA.length && (firstIndexOf(buf, 0, START_DATA) == -1)) {
      bufSize = 0;
      log.error(sm.getString("xByteBuffer.discarded.invalidHeader"));
      return false;
    }
  }
  return true;
}

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

/**
 * Receive a datagram packet, locking wait
 * @throws IOException
 */
public void receive() throws IOException {
  boolean checkexpired = true;
  try {
    
    socket.receive(receivePacket);
    if(receivePacket.getLength() > MAX_PACKET_SIZE) {
      log.error("Multicast packet received was too long, dropping package:"+receivePacket.getLength());
    } else {
      byte[] data = new byte[receivePacket.getLength()];
      System.arraycopy(receivePacket.getData(), receivePacket.getOffset(), data, 0, data.length);
      if (XByteBuffer.firstIndexOf(data,0,MemberImpl.TRIBES_MBR_BEGIN)==0) {
        memberDataReceived(data);
      } else {
        memberBroadcastsReceived(data);
      }
      
    }
  } catch (SocketTimeoutException x ) { 
    //do nothing, this is normal, we don't want to block forever
    //since the receive thread is the same thread
    //that does membership expiration
  }
  if (checkexpired) checkExpired();
}

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

/**
 * Receive a datagram packet, locking wait
 * @throws IOException
 */
public void receive() throws IOException {
  boolean checkexpired = true;
  try {
    socket.receive(receivePacket);
    if(receivePacket.getLength() > MAX_PACKET_SIZE) {
      log.error("Multicast packet received was too long, dropping package:"+receivePacket.getLength());
    } else {
      byte[] data = new byte[receivePacket.getLength()];
      System.arraycopy(receivePacket.getData(), receivePacket.getOffset(), data, 0, data.length);
      if (XByteBuffer.firstIndexOf(data,0,MemberImpl.TRIBES_MBR_BEGIN)==0) {
        memberDataReceived(data);
      } else {
        memberBroadcastsReceived(data);
      }
    }
  } catch (SocketTimeoutException x ) {
    //do nothing, this is normal, we don't want to block forever
    //since the receive thread is the same thread
    //that does membership expiration
  }
  if (checkexpired) checkExpired();
}

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

/**
 * Receive a datagram packet, locking wait
 * @throws IOException Received failed
 */
public void receive() throws IOException {
  boolean checkexpired = true;
  try {
    socket.receive(receivePacket);
    if(receivePacket.getLength() > MAX_PACKET_SIZE) {
      log.error(sm.getString("mcastServiceImpl.packet.tooLong",
          Integer.toString(receivePacket.getLength())));
    } else {
      byte[] data = new byte[receivePacket.getLength()];
      System.arraycopy(receivePacket.getData(), receivePacket.getOffset(), data, 0, data.length);
      if (XByteBuffer.firstIndexOf(data,0,MemberImpl.TRIBES_MBR_BEGIN)==0) {
        memberDataReceived(data);
      } else {
        memberBroadcastsReceived(data);
      }
    }
  } catch (SocketTimeoutException x ) {
    //do nothing, this is normal, we don't want to block forever
    //since the receive thread is the same thread
    //that does membership expiration
  }
  if (checkexpired) checkExpired();
}

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

if (XByteBuffer.firstIndexOf(data,offset,TRIBES_MBR_BEGIN)!=pos) {
  throw new IllegalArgumentException("Invalid package, should start with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_BEGIN));
if (XByteBuffer.firstIndexOf(data,endpos,TRIBES_MBR_END)!=endpos) {
  throw new IllegalArgumentException("Invalid package, should end with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_END));

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

if (XByteBuffer.firstIndexOf(data,offset,TRIBES_MBR_BEGIN)!=pos) {
  throw new IllegalArgumentException("Invalid package, should start with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_BEGIN));
if (XByteBuffer.firstIndexOf(data,endpos,TRIBES_MBR_END)!=endpos) {
  throw new IllegalArgumentException("Invalid package, should end with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_END));

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

if (XByteBuffer.firstIndexOf(data,offset,TRIBES_MBR_BEGIN)!=pos) {
  throw new IllegalArgumentException("Invalid package, should start with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_BEGIN));
if (XByteBuffer.firstIndexOf(data,endpos,TRIBES_MBR_END)!=endpos) {
  throw new IllegalArgumentException("Invalid package, should end with:"+org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_END));

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

if (XByteBuffer.firstIndexOf(data,offset,TRIBES_MBR_BEGIN)!=pos) {
  throw new IllegalArgumentException(sm.getString("memberImpl.invalid.package.begin", org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_BEGIN)));
if (XByteBuffer.firstIndexOf(data,endpos,TRIBES_MBR_END)!=endpos) {
  throw new IllegalArgumentException(sm.getString("memberImpl.invalid.package.end", org.apache.catalina.tribes.util.Arrays.toString(TRIBES_MBR_END)));

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