com.sun.grizzly.util.Utils.findBytes()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.2k)|赞(0)|评价(0)|浏览(111)

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

Utils.findBytes介绍

[英]Specialized utility method: find a sequence of lower case bytes inside a ByteBuffer.
[中]专门的实用方法:在字节缓冲区中查找小写字节序列。

代码示例

代码示例来源:origin: com.sun.grizzly/grizzly-http

/**
 * Introspect the request and determine if the target url can
 * execute under {@link AsyncHandler} or not.
 * @param bb The current byteBuffer.
 * @param handlerCode - no used.
 * @return An {@link Interceptor} value determining if an {@link AsyncHandler} 
 * should be allowed to execute or not.
 * @throws java.io.IOException
 */
public int handle(ByteBuffer bb, int handlerCode) throws IOException {
  int pos = bb.position();
  int limit = bb.limit();
  
  try{
    // TODO: Add patten matching.
    for (byte[] b: allowed){
      if (Utils.findBytes(bb,b) > -1){
        return Interceptor.CONTINUE;
      }
    }
    
  } finally {
    bb.position(pos);
    bb.limit(limit);
  }
  return Interceptor.BREAK;
}

代码示例来源:origin: org.glassfish.external/grizzly-module

while(iterator.hasNext()){
  matchBytes = iterator.next();
  if (Utils.findBytes(bb,matchBytes) > -1){
    log("Find match: " + (new String(matchBytes)) 
          + " Suspending: " + ctx.getSelectionKey());

相关文章

微信公众号

最新文章

更多