Example usage for io.netty.buffer Unpooled LITTLE_ENDIAN

List of usage examples for io.netty.buffer Unpooled LITTLE_ENDIAN

Introduction

In this page you can find the example usage for io.netty.buffer Unpooled LITTLE_ENDIAN.

Prototype

ByteOrder LITTLE_ENDIAN

To view the source code for io.netty.buffer Unpooled LITTLE_ENDIAN.

Click Source Link

Document

Little endian byte order.

Usage

From source file:org.apache.reef.wake.remote.transport.netty.ChunkedReadWriteHandler.java

License:Apache License

/**
 * Converts the int size into a byte[]//from  ww w .ja v a 2  s.  com
 *
 * @return the bit representation of size
 */
private byte[] sizeAsByteArr(final int size) {
    final byte[] ret = new byte[INT_SIZE];
    final ByteBuf intBuffer = Unpooled.wrappedBuffer(ret).order(Unpooled.LITTLE_ENDIAN);
    intBuffer.clear();
    intBuffer.writeInt(size);
    intBuffer.release();
    return ret;
}

From source file:org.apache.reef.wake.remote.transport.netty.ChunkedReadWriteHandler.java

License:Apache License

/**
 * Get expected size encoded as offset + 4 bytes of data
 *//*from  www  .j av a  2 s. c om*/
private int getSize(final byte[] data, final int offset) {

    if (data.length - offset < INT_SIZE) {
        return 0;
    }

    final ByteBuf intBuffer = Unpooled.wrappedBuffer(data, offset, INT_SIZE).order(Unpooled.LITTLE_ENDIAN);
    final int ret = intBuffer.readInt();
    intBuffer.release();

    return ret;
}

From source file:org.comtel2000.opcua.client.service.OpcUaConverter.java

License:Apache License

public static String toRangeString(ByteString bs) {
    if (bs == null || bs.bytes() == null || bs.bytes().length != 16) {
        return "Range [unknown]";
    }/*w  ww. j a  v a2 s . c o  m*/
    ByteBuf range = Unpooled.wrappedBuffer(bs.bytes()).order(Unpooled.LITTLE_ENDIAN);
    double low = range.readDouble();
    double high = range.readDouble();
    return String.format("Range [%s, %s]", toString(low), toString(high));
}

From source file:org.comtel2000.opcua.client.service.OpcUaConverter.java

License:Apache License

public static String toEUInformationString(ByteString bs) {
    if (bs == null || bs.bytes() == null) {
        return "EUInformation [unknown]";
    }//  ww w. ja  v  a  2  s .  c o m
    BinaryDecoder decoder = new BinaryDecoder();
    decoder.setBuffer(Unpooled.wrappedBuffer(bs.bytes()).order(Unpooled.LITTLE_ENDIAN));
    EUInformation eui = EUInformation.decode(decoder);
    return eui.toString();
}