Example usage for io.netty.buffer ByteBuf writeDouble

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

Introduction

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

Prototype

public abstract ByteBuf writeDouble(double value);

Source Link

Document

Sets the specified 64-bit floating point number at the current writerIndex and increases the writerIndex by 8 in this buffer.

Usage

From source file:com.crowsofwar.gorecore.util.Vector.java

License:Open Source License

/**
 * Writes this vector to the packet byte buffer.
 * /*from  w ww  .ja  v  a 2s. co  m*/
 * @param buf
 *            Buffer to write to
 */
public void toBytes(ByteBuf buf) {
    buf.writeDouble(x());
    buf.writeDouble(y());
    buf.writeDouble(z());
}

From source file:com.Da_Technomancer.crossroads.API.packets.Message.java

License:Creative Commons License

private static void writeDouble(double d, ByteBuf buf) {
    buf.writeDouble(d);
}

From source file:com.Da_Technomancer.crossroads.API.packets.Message.java

License:Creative Commons License

private static void writeDoubleArray(double[] doubles, ByteBuf buf) {
    buf.writeInt(doubles.length);//from  w  ww .  jav  a  2 s .  com
    for (double inner : doubles) {
        buf.writeDouble(inner);
    }
}

From source file:com.heliosapm.ohcrs.core.AbstractDriverCodec.java

License:Apache License

/**
 * {@inheritDoc}/*from  w w  w . j  av  a  2s . c o m*/
 * @see com.heliosapm.ohcrs.core.DriverCodec#write(double, io.netty.buffer.ByteBuf)
 */
@Override
public int write(final Double p, final ByteBuf b) throws SQLException {
    prefix(p, DBType.DOUBLE, b);
    b.writeDouble(p);
    return b.writerIndex();
}

From source file:com.heliosapm.ohcrs.core.AbstractDriverCodec.java

License:Apache License

/**
 * {@inheritDoc}//w  w  w  . j  a  v  a  2s  .  co  m
 * @see com.heliosapm.ohcrs.core.DriverCodec#write(double, io.netty.buffer.ByteBuf)
 */
@Override
public int write(final double p, final ByteBuf b) throws SQLException {
    prefix(P, DBType.DOUBLE, b);
    b.writeDouble(p);
    return b.writerIndex();
}

From source file:com.heliosapm.streams.metrics.StreamedMetricValue.java

License:Apache License

/**
 * Writes a metric to the passed buffer/*w w  w .j  ava  2  s . co  m*/
 * @param buff The buffer to write to
 * @param valueType The value type
 * @param metricName The metric name
 * @param timestamp The metric timestamp
 * @param value The metric value
 * @param tags The metric tags
 * @return the number of bytes written
 */
public static int write(final ByteBuf buff, final ValueType valueType, final String metricName,
        final long timestamp, final double value, final Map<String, String> tags) {
    final int defSize = write(buff, valueType, metricName, timestamp, tags);
    buff.writeByte(0);
    buff.writeDouble(value);
    return defSize + 9;
}

From source file:com.heliosapm.streams.metrics.StreamedMetricValue.java

License:Apache License

/**
 * Returns a byte array containing the serialized streammetric
 * @return a byte array /*from   w  w w  .  j a v a  2  s  .  c  o m*/
 */
@Override
public byte[] toByteArray() {
    final ByteBuf buff = BufferManager.getInstance().directBuffer(byteSize);
    try {
        buff.writeByte(TYPE_CODE);
        writeByteArray(buff);
        if (isDoubleValue) {
            buff.writeByte(0);
            buff.writeDouble(doubleValue);
        } else {
            buff.writeByte(1);
            buff.writeLong(longValue);
        }
        return ByteBufUtil.getBytes(buff, 0, buff.readableBytes());
    } finally {
        try {
            buff.release();
        } catch (Exception x) {
            /* No Op */}
    }
}

From source file:com.heliosapm.streams.metrics.StreamedMetricValue.java

License:Apache License

/**
 * Returns this streamed metric serialized into a byte buf
 * @return the byte buf/*from  w  w  w  .j  ava  2s . c  o  m*/
 */
@Override
public ByteBuf toByteBuff() {
    final ByteBuf buff = BufferManager.getInstance().directBuffer(byteSize);
    buff.writeByte(TYPE_CODE);
    writeByteArray(buff);
    if (isDoubleValue) {
        buff.writeByte(0);
        buff.writeDouble(doubleValue);
    } else {
        buff.writeByte(1);
        buff.writeLong(longValue);
    }
    return buff;
}

From source file:com.heliosapm.streams.metrics.StreamedMetricValue.java

License:Apache License

/**
 * Writes this metric into the passed buffer
 * @param buff The buffer to write this metric into
 *///w ww  .  j a v a  2 s.  co  m
@Override
public void intoByteBuf(final ByteBuf buff) {
    buff.writeByte(TYPE_CODE);
    writeByteArray(buff);
    if (isDoubleValue) {
        buff.writeByte(0);
        buff.writeDouble(doubleValue);
    } else {
        buff.writeByte(1);
        buff.writeLong(longValue);
    }
}

From source file:com.minemaarten.signals.network.PacketSpawnParticle.java

License:LGPL

@Override
public void toBytes(ByteBuf buffer) {
    super.toBytes(buffer);
    buffer.writeInt(particleId);/*from   ww  w  .  j  av a 2s. c om*/
    buffer.writeDouble(dx);
    buffer.writeDouble(dy);
    buffer.writeDouble(dz);
}