Example usage for io.netty.buffer ByteBuf getCharSequence

List of usage examples for io.netty.buffer ByteBuf getCharSequence

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf getCharSequence.

Prototype

public abstract CharSequence getCharSequence(int index, int length, Charset charset);

Source Link

Document

Gets a CharSequence with the given length at the given index.

Usage

From source file:io.reactiverse.pgclient.StringLongSequenceTest.java

License:Apache License

private static void assertEquals(String s, long l) {
    ByteBuf buf = Unpooled.buffer();
    buf.writeLong(l);/*  w ww  . j  a  va 2  s.co  m*/
    String actual = buf.getCharSequence(0, 7, StandardCharsets.UTF_8).toString();
    Assert.assertEquals(s, actual);
}

From source file:org.traccar.protocol.L100FrameDecoder.java

License:Apache License

@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {

    if (buf.readableBytes() < 10) {
        return null;
    }//from w w w .java  2s .  c o  m

    if (buf.getCharSequence(buf.readerIndex(), 4, StandardCharsets.US_ASCII).toString().equals("ATL,")) {
        return decodeNew(buf);
    } else {
        return decodeOld(buf);
    }
}