當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。