当前位置: 首页>>代码示例>>Java>>正文


Java ByteBuf.forEachByte方法代码示例

本文整理汇总了Java中io.netty.buffer.ByteBuf.forEachByte方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuf.forEachByte方法的具体用法?Java ByteBuf.forEachByte怎么用?Java ByteBuf.forEachByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.buffer.ByteBuf的用法示例。


在下文中一共展示了ByteBuf.forEachByte方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: split

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public Iterable<String> split(final ByteBuf buffer, final Charset charset, final boolean includeRemainingData) {
    return () -> new AbstractIterator<String>() {
        @Override
        protected String computeNext() {
            ByteBuf fullLine = null;
            try {
                if (!buffer.isReadable()) {
                    return endOfData();
                }
                final int i = buffer.forEachByte(ByteBufProcessor.FIND_CRLF);
                if (i == -1) {
                    if (includeRemainingData) {
                        final ByteBuf remaining = buffer.readBytes(buffer.readableBytes());
                        return remaining.toString(charset);
                    } else {
                        return endOfData();
                    }
                }
                fullLine = buffer.readBytes(i);
                // Strip the \r/\n bytes from the buffer.
                final byte readByte = buffer.readByte(); // the \r or \n byte
                if (readByte == '\r') {
                    buffer.readByte(); // the \n byte if previous was \r
                }
                return fullLine.toString(charset);
            } finally {
                buffer.discardReadBytes();
                if (fullLine != null) {
                    fullLine.release();
                }

            }
        }
    };
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:37,代码来源:NewlineChunkSplitter.java

示例2: process

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
protected ByteBuf process(final StreamCipher cipher, ByteBuf data) {
    final ByteBuf slice = data.slice();
    slice.writerIndex(0);
    data.forEachByte(data.readerIndex(), data.readableBytes(), new ByteBufProcessor() {
        @Override
        public boolean process(byte b) throws Exception {
            slice.writeByte(cipher.returnByte(b));
            return true;
        }
    });
    return data;
}
 
开发者ID:zhoulifu,项目名称:ss-java,代码行数:14,代码来源:AbstractBouncycastleCrypto.java

示例3: parse

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public String parse(ByteBuf buffer) {
  seq = sequenceReference.get();

  seq.reset();
  size = 0;
  int i = buffer.forEachByte(this);
  buffer.readerIndex(i + 1);

  String result = seq.toString();
  seq = null;

  return result;
}
 
开发者ID:HubSpot,项目名称:NioImapClient,代码行数:14,代码来源:BaseStringParser.java

示例4: parse

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
public long parse(ByteBuf in) {
  seq = sequenceRef.get();

  seq.reset();
  size = 0;
  int i = in.forEachByte(this);
  in.readerIndex(i);

  Long result = Long.parseLong(seq.toString());
  seq = null;

  return result;
}
 
开发者ID:HubSpot,项目名称:NioImapClient,代码行数:14,代码来源:NumberParser.java

示例5: findDotAtBeginningOfLine

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
private static int findDotAtBeginningOfLine(ByteBuf buffer, int startAt, byte[] previousBytes) {
  int length = buffer.readableBytes();

  if (previousBytes[0] == CR && previousBytes[1] == LF && buffer.getByte(startAt) == DOT) {
    return startAt;
  }

  if (previousBytes[1] == CR && length >= 2 && buffer.getByte(startAt) == LF && buffer.getByte(startAt + 1) == DOT) {
    return startAt + 1;
  }

  int i = startAt;
  while (++i < length) {
    i = buffer.forEachByte(i, length - i, ByteProcessor.FIND_LF);
    if (i == -1) {
      return -1;
    }

    if (buffer.getByte(i - 1) == CR) {
      if (i + 1 < length && buffer.getByte(i + 1) == DOT) {
        return i + 1;
      } else {
        continue;
      }
    }
  }

  return -1;
}
 
开发者ID:HubSpot,项目名称:NioSmtpClient,代码行数:30,代码来源:DotStuffing.java

示例6: byteBufProcessor

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
/**
 * Listing 5.9
 */
public static void byteBufProcessor(ByteBuf buffer) {
    int index = buffer.forEachByte(ByteBufProcessor.FIND_CR);
}
 
开发者ID:zy416548283,项目名称:NettyStudy,代码行数:7,代码来源:ByteBufExamples.java

示例7: parse

import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
int parse(ByteBuf in) {
  afterSpace = false;
  rows = 0;
  in.forEachByte(in.readerIndex(), in.readableBytes() - 1, this);
  return rows;
}
 
开发者ID:vietj,项目名称:reactive-pg-client,代码行数:7,代码来源:MessageDecoder.java


注:本文中的io.netty.buffer.ByteBuf.forEachByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。