public void setString(String value) {
   char[] temp = ((String) value).toCharArray();
   this.setInt((Integer) temp.length);
   for (int i = 0; i < temp.length; i++) {
     data.writeChar(temp[i]);
   }
 }
Пример #2
0
  @Override
  public void toBytes(ByteBuf buf) {
    buf.writeInt(posX);
    buf.writeInt(posY);
    buf.writeInt(posZ);
    buf.writeInt(data.size());

    for (int i = 0; i < data.size(); i++) {
      Object obj = data.get(i);
      if (obj instanceof Character) {
        buf.writeByte(0x00);
        buf.writeChar((Character) obj);
      } else if (obj instanceof String) {
        buf.writeByte(0x01);
        writeString(buf, (String) obj);
      } else if (obj instanceof Float) {
        buf.writeByte(0x02);
        buf.writeFloat((Float) obj);
      } else if (obj instanceof Double) {
        buf.writeByte(0x03);
        buf.writeDouble((Double) obj);
      } else if (obj instanceof Byte) {
        buf.writeByte(0x04);
        buf.writeByte((Byte) obj);
      } else if (obj instanceof Long) {
        buf.writeByte(0x05);
        buf.writeLong((Long) obj);
      } else {
        buf.writeByte(0x0F);
        buf.writeInt((Integer) obj);
      }
    }
  }
Пример #3
0
 @Override
 public void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception {
   while (in.readableBytes() >= 2) {
     int value = in.readShort();
     out.writeChar(value * value);
   }
 }
Пример #4
0
 @Override
 public MessageBuffer<ByteBuf> writeChar(int value) {
   buffer.writeChar(value);
   return this;
 }
Пример #5
0
 @Override
 public ByteBuf writeChar(int value) {
   return buf.writeChar(value);
 }
 @Override
 public ByteBuf writeChar(int var1) {
   return a.writeChar(var1);
 }