Example usage for io.netty.buffer ByteBuf writeLong

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

Introduction

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

Prototype

public abstract ByteBuf writeLong(long value);

Source Link

Document

Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.

Usage

From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java

License:Apache License

private static void binaryEncodeINT8(Number value, ByteBuf buff) {
    buff.writeLong(value.longValue());
}

From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java

License:Apache License

private static void binaryEncodeTIME(LocalTime value, ByteBuf buff) {
    buff.writeLong(value.getLong(ChronoField.MICRO_OF_DAY));
}

From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java

License:Apache License

private static void binaryEncodeTIMETZ(OffsetTime value, ByteBuf buff) {
    buff.writeLong(value.toLocalTime().getLong(ChronoField.MICRO_OF_DAY));
    // zone offset in seconds (should we change it to UTC ?)
    buff.writeInt(-value.getOffset().getTotalSeconds());
}

From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java

License:Apache License

private static void binaryEncodeTIMESTAMP(LocalDateTime value, ByteBuf buff) {
    buff.writeLong(-value.until(LOCAL_DATE_TIME_EPOCH, ChronoUnit.MICROS));
}

From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java

License:Apache License

private static void binaryEncodeTIMESTAMPTZ(OffsetDateTime value, ByteBuf buff) {
    buff.writeLong(-value.until(OFFSET_DATE_TIME_EPOCH, ChronoUnit.MICROS));
}

From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java

License:Apache License

private static void binaryEncodeUUID(UUID uuid, ByteBuf buff) {
    buff.writeLong(uuid.getMostSignificantBits());
    buff.writeLong(uuid.getLeastSignificantBits());
}

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);
    String actual = buf.getCharSequence(0, 7, StandardCharsets.UTF_8).toString();
    Assert.assertEquals(s, actual);/*from ww w.ja va 2s . co  m*/
}

From source file:it.kytech.smartccraft.network.message.MessageTileChargeStation.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(x);/*from   w w w.j  av  a2  s  .c  om*/
    buf.writeInt(y);
    buf.writeInt(z);
    buf.writeByte(orientation);
    buf.writeByte(state);
    buf.writeInt(customName.length());
    buf.writeBytes(customName.getBytes());
    if (ownerUUID != null) {
        buf.writeBoolean(true);
        buf.writeLong(ownerUUID.getMostSignificantBits());
        buf.writeLong(ownerUUID.getLeastSignificantBits());
    } else {
        buf.writeBoolean(false);
    }
    buf.writeByte(status);
}

From source file:it.kytech.smartccraft.network.message.MessageTileEntitySCC.java

License:Open Source License

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(x);//  w w w  . ja v a 2 s.c  om
    buf.writeInt(y);
    buf.writeInt(z);
    buf.writeByte(orientation);
    buf.writeByte(state);
    buf.writeInt(customName.length());
    buf.writeBytes(customName.getBytes());
    if (ownerUUID != null) {
        buf.writeBoolean(true);
        buf.writeLong(ownerUUID.getMostSignificantBits());
        buf.writeLong(ownerUUID.getLeastSignificantBits());
    } else {
        buf.writeBoolean(false);
    }
    toBytesChild(buf);
}

From source file:ivorius.ivtoolkit.network.IvPacketHelper.java

License:Apache License

public static void writeNumber(ByteBuf buffer, Number number) {
    if (number instanceof Byte) {
        buffer.writeByte((Byte) number);
    } else if (number instanceof Double) {
        buffer.writeDouble((Double) number);
    } else if (number instanceof Float) {
        buffer.writeFloat((Float) number);
    } else if (number instanceof Integer) {
        buffer.writeInt((Integer) number);
    } else if (number instanceof Long) {
        buffer.writeLong((Long) number);
    } else if (number instanceof Short) {
        buffer.writeShort((Short) number);
    } else {//from  w w w  . j  a  v a2 s  .c o m
        throw new IllegalArgumentException();
    }
}