@Override
 public boolean serialize(final ByteBuffer buffer) {
   if (this.contents.size() > 65535) {
     return false;
   }
   buffer.putShort((short) this.contents.size());
   for (int i = 0; i < this.contents.size(); ++i) {
     final Content contents_element = this.contents.get(i);
     final boolean contents_element_ok = contents_element.serialize(buffer);
     if (!contents_element_ok) {
       return false;
     }
   }
   if (this.contentsSelection != null) {
     buffer.put((byte) 1);
     final boolean contentsSelection_ok = this.contentsSelection.serialize(buffer);
     if (!contentsSelection_ok) {
       return false;
     }
   } else {
     buffer.put((byte) 0);
   }
   if (this.buyableContents.size() > 65535) {
     return false;
   }
   buffer.putShort((short) this.buyableContents.size());
   for (int i = 0; i < this.buyableContents.size(); ++i) {
     final BuyableContent buyableContents_element = this.buyableContents.get(i);
     final boolean buyableContents_element_ok = buyableContents_element.serialize(buffer);
     if (!buyableContents_element_ok) {
       return false;
     }
   }
   return true;
 }
Пример #2
0
 @Override
 public boolean unserialize(final ByteBuffer buffer) {
   this.referenceId = buffer.getInt();
   this.level = buffer.getShort();
   this.xp = buffer.getLong();
   return true;
 }
Пример #3
0
 @Override
 public boolean serialize(final ByteBuffer buffer) {
   buffer.putInt(this.referenceId);
   buffer.putShort(this.level);
   buffer.putLong(this.xp);
   return true;
 }
 @Override
 public boolean unserialize(final ByteBuffer buffer) {
   final int contents_size = buffer.getShort() & 0xFFFF;
   this.contents.clear();
   this.contents.ensureCapacity(contents_size);
   for (int i = 0; i < contents_size; ++i) {
     final Content contents_element = new Content();
     final boolean contents_element_ok = contents_element.unserialize(buffer);
     if (!contents_element_ok) {
       return false;
     }
     this.contents.add(contents_element);
   }
   final boolean contentsSelection_present = buffer.get() == 1;
   if (contentsSelection_present) {
     this.contentsSelection = new ContentsSelection();
     final boolean contentsSelection_ok = this.contentsSelection.unserialize(buffer);
     if (!contentsSelection_ok) {
       return false;
     }
   } else {
     this.contentsSelection = null;
   }
   final int buyableContents_size = buffer.getShort() & 0xFFFF;
   this.buyableContents.clear();
   this.buyableContents.ensureCapacity(buyableContents_size);
   for (int j = 0; j < buyableContents_size; ++j) {
     final BuyableContent buyableContents_element = new BuyableContent();
     final boolean buyableContents_element_ok = buyableContents_element.unserialize(buffer);
     if (!buyableContents_element_ok) {
       return false;
     }
     this.buyableContents.add(buyableContents_element);
   }
   return true;
 }
 private boolean unserialize_v0(final ByteBuffer buffer) {
   final int contentsSelection_size = buffer.getShort() & 0xFFFF;
   this.contentsSelection.clear();
   this.contentsSelection.ensureCapacity(contentsSelection_size);
   for (int i = 0; i < contentsSelection_size; ++i) {
     final ContentSelection contentsSelection_element = new ContentSelection();
     final boolean contentsSelection_element_ok =
         contentsSelection_element.unserializeVersion(buffer, 0);
     if (!contentsSelection_element_ok) {
       return false;
     }
     this.contentsSelection.add(contentsSelection_element);
   }
   return true;
 }
 @Override
 public boolean serialize(final ByteBuffer buffer) {
   if (this.contentsSelection.size() > 65535) {
     return false;
   }
   buffer.putShort((short) this.contentsSelection.size());
   for (int i = 0; i < this.contentsSelection.size(); ++i) {
     final ContentSelection contentsSelection_element = this.contentsSelection.get(i);
     final boolean contentsSelection_element_ok = contentsSelection_element.serialize(buffer);
     if (!contentsSelection_element_ok) {
       return false;
     }
   }
   return true;
 }
 @Override
 public boolean unserialize(final ByteBuffer buffer) {
   this.referenceId = buffer.getInt();
   this.price = buffer.getInt();
   return true;
 }
 @Override
 public boolean serialize(final ByteBuffer buffer) {
   buffer.putInt(this.referenceId);
   buffer.putInt(this.price);
   return true;
 }
 @Override
 public boolean unserialize(final ByteBuffer buffer) {
   this.referenceId = buffer.getInt();
   this.remainingDuration = buffer.getInt();
   return true;
 }
 @Override
 public boolean serialize(final ByteBuffer buffer) {
   buffer.putInt(this.referenceId);
   buffer.putInt(this.remainingDuration);
   return true;
 }