Example usage for io.netty.buffer ByteBuf readBoolean

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

Introduction

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

Prototype

public abstract boolean readBoolean();

Source Link

Document

Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.

Usage

From source file:hellfirepvp.astralsorcery.common.network.packet.server.PktSyncKnowledge.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.state = buf.readByte();

    int cLength = buf.readInt();
    if (cLength != -1) {
        knownConstellations = new ArrayList<>(cLength);
        for (int i = 0; i < cLength; i++) {
            String val = ByteBufUtils.readString(buf);
            knownConstellations.add(val);
        }/*from  w  w  w  .java 2  s . c om*/
    } else {
        knownConstellations = new ArrayList<>();
    }

    cLength = buf.readInt();
    if (cLength != -1) {
        seenConstellations = new ArrayList<>(cLength);
        for (int i = 0; i < cLength; i++) {
            String val = ByteBufUtils.readString(buf);
            seenConstellations.add(val);
        }
    } else {
        seenConstellations = new ArrayList<>();
    }

    int rLength = buf.readInt();
    if (rLength != -1) {
        researchProgression = new ArrayList<>(rLength);
        for (int i = 0; i < rLength; i++) {
            researchProgression.add(ResearchProgression.getById(buf.readInt()));
        }
    } else {
        researchProgression = new ArrayList<>();
    }

    int attunementPresent = buf.readByte();
    if (attunementPresent != -1) {
        String attunement = ByteBufUtils.readString(buf);
        IConstellation c = ConstellationRegistry.getConstellationByName(attunement);
        if (c == null || !(c instanceof IMajorConstellation)) {
            AstralSorcery.log.warn(
                    "[AstralSorcery] received constellation-attunement progress-packet with unknown constellation: "
                            + attunement);
        } else {
            this.attunedConstellation = (IMajorConstellation) c;
        }
    }

    int perkLength = buf.readInt();
    if (perkLength != -1) {
        this.appliedPerks = new HashMap<>(perkLength);
        for (int i = 0; i < perkLength; i++) {
            int id = buf.readInt();
            int lvl = buf.readInt();
            this.appliedPerks.put(ConstellationPerks.getById(id).getSingleInstance(), lvl);
        }
    } else {
        this.appliedPerks = new HashMap<>();
    }

    this.wasOnceAttuned = buf.readBoolean();
    this.progressTier = buf.readInt();
    this.alignmentCharge = buf.readDouble();
}

From source file:hellfirepvp.astralsorcery.common.network.packet.server.PktUpdateReach.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.apply = buf.readBoolean();
    this.modifier = buf.readFloat();
}

From source file:hellfirepvp.astralsorcery.common.util.ByteBufUtils.java

License:Open Source License

@Nonnull
public static ItemStack readItemStack(ByteBuf byteBuf) {
    boolean defined = byteBuf.readBoolean();
    if (defined) {
        return new ItemStack(readNBTTag(byteBuf));
    } else {//  w  ww  . jav  a2s .  c om
        return ItemStack.EMPTY;
    }
}

From source file:hellfirepvp.astralsorcery.common.util.ByteBufUtils.java

License:Open Source License

@Nullable
public static FluidStack readFluidStack(ByteBuf byteBuf) {
    boolean defined = byteBuf.readBoolean();
    if (defined) {
        return FluidStack.loadFluidStackFromNBT(readNBTTag(byteBuf));
    } else {// ww  w  . j ava  2s.  c om
        return null;
    }
}

From source file:herddb.proto.PduCodec.java

License:Apache License

public static Object readObject(ByteBuf dii) {

    int type = ByteBufUtils.readVInt(dii);

    switch (type) {
    case TYPE_BYTEARRAY:
        return ByteBufUtils.readArray(dii);
    case TYPE_LONG:
        return dii.readLong();
    case TYPE_INTEGER:
        return dii.readInt();
    case TYPE_SHORT:
        return dii.readShort();
    case TYPE_BYTE:
        return dii.readByte();
    case TYPE_STRING:
        return ByteBufUtils.readUnpooledRawString(dii);
    case TYPE_TIMESTAMP:
        return new java.sql.Timestamp(dii.readLong());
    case TYPE_NULL:
        return null;
    case TYPE_BOOLEAN:
        return dii.readBoolean();
    case TYPE_DOUBLE:
        return dii.readDouble();
    default:/* www  . java 2s .  co  m*/
        throw new IllegalArgumentException("bad column type " + type);
    }
}

From source file:hivemall.mix.MixMessageDecoder.java

License:Open Source License

@Override
protected MixMessage decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
    ByteBuf frame = (ByteBuf) super.decode(ctx, in);
    if (frame == null) {
        return null;
    }//ww  w . java  2s  .  c  o  m

    byte b = frame.readByte();
    MixEventName event = MixEventName.resolve(b);
    Object feature = decodeObject(frame);
    float weight = frame.readFloat();
    float covariance = frame.readFloat();
    short clock = frame.readShort();
    int deltaUpdates = frame.readInt();
    boolean cancelRequest = frame.readBoolean();
    String groupID = readString(frame);

    MixMessage msg = new MixMessage(event, feature, weight, covariance, clock, deltaUpdates, cancelRequest);
    msg.setGroupID(groupID);
    return msg;
}

From source file:io.github.vastframework.codecs.primitives.DecodingPrimitiveSupport.java

License:Apache License

default boolean decodeBoolean(ByteBuf buffer) {
    return buffer.readBoolean();
}

From source file:io.hydramq.core.type.converters.MessagePropertiesConverter.java

License:Open Source License

@Override
public MessageProperties read(final ConversionContext context, final ByteBuf buffer) {
    MessageProperties properties = new MessageProperties();
    int flags = buffer.readInt();
    if ((flags & HAS_STRING_PROPERTIES) == HAS_STRING_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setString(context.read(String.class, buffer), context.read(String.class, buffer));
        }/*from  ww  w . j a v  a 2 s  . co m*/
    }
    if ((flags & HAS_BOOLEAN_PROPERTIES) == HAS_BOOLEAN_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setBoolean(context.read(String.class, buffer), buffer.readBoolean());
        }
    }
    if ((flags & HAS_INTEGER_PROPERTIES) == HAS_INTEGER_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setInteger(context.read(String.class, buffer), buffer.readInt());
        }
    }
    if ((flags & HAS_LONG_PROPERTIES) == HAS_LONG_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setLong(context.read(String.class, buffer), buffer.readLong());
        }
    }
    if ((flags & HAS_FLOAT_PROPERTIES) == HAS_FLOAT_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setFloat(context.read(String.class, buffer), buffer.readFloat());
        }
    }
    if ((flags & HAS_DOUBLE_PROPERTIES) == HAS_DOUBLE_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setDouble(context.read(String.class, buffer), buffer.readDouble());
        }
    }
    if ((flags & HAS_BYTES_PROPERTIES) == HAS_BYTES_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setBytes(context.read(String.class, buffer), context.read(byte[].class, buffer));
        }
    }
    if ((flags & HAS_SHORT_PROPERTIES) == HAS_SHORT_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setShort(context.read(String.class, buffer), buffer.readShort());
        }
    }
    if ((flags & HAS_BYTE_PROPERTIES) == HAS_BYTE_PROPERTIES) {
        int count = buffer.readInt();
        for (int i = 0; i < count; i++) {
            properties.setByte(context.read(String.class, buffer), buffer.readByte());
        }
    }

    return properties;
}

From source file:io.servicecomb.foundation.vertx.TestStream.java

License:Apache License

@Test
public void testBufferInputStream() {
    ByteBuf obuf = Buffer.buffer(DIRECT_BUFFER_SIZE).getByteBuf();
    obuf.writeBytes(("testss").getBytes());
    @SuppressWarnings("resource")
    BufferInputStream oBufferInputStream = new BufferInputStream(obuf);
    Assert.assertNotEquals(1234, oBufferInputStream.skip(0));
    Assert.assertNotEquals(obuf.readByte(), oBufferInputStream.readByte());
    Assert.assertEquals(obuf.readByte() + 1, oBufferInputStream.read());
    Assert.assertEquals(obuf.readBoolean(), oBufferInputStream.readBoolean());
    Assert.assertEquals(obuf.readerIndex(), oBufferInputStream.getIndex());
    Assert.assertEquals(obuf.readableBytes(), oBufferInputStream.available());
    Assert.assertNotEquals(null, oBufferInputStream.read(("test").getBytes()));
}

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

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    this.x = buf.readInt();
    this.y = buf.readInt();
    this.z = buf.readInt();
    this.orientation = buf.readByte();
    this.state = buf.readByte();
    int customNameLength = buf.readInt();
    this.customName = new String(buf.readBytes(customNameLength).array());
    if (buf.readBoolean()) {
        this.ownerUUID = new UUID(buf.readLong(), buf.readLong());
    } else {//from  w  ww  . jav  a 2 s.c o  m
        this.ownerUUID = null;
    }
    this.status = buf.readByte();
}