Ejemplo n.º 1
0
 @Override
 public int getBitsCount() {
   int additionalBits = 0;
   for (ResourceObject currentResource : resources) {
     additionalBits += currentResource.getBitsCount();
   }
   return super.getBitsCount() + leavingPeerInfo.getBitsCount() + additionalBits;
 }
Ejemplo n.º 2
0
 @Override
 public int getBitsCount() {
   int additionalBits = 0;
   if (this.vset != null) {
     int vsetSize = this.vset.size();
     for (int i = 0; i < vsetSize; i++) {
       PeerInfo currentPeerInfo = this.vset.get(i);
       additionalBits += currentPeerInfo.getBitsCount();
     }
   }
   return super.getBitsCount() + this.originatorPeerInfo.getBitsCount() + additionalBits;
 }
Ejemplo n.º 3
0
  @Override
  protected byte[] asBytes(int bitsCount) {
    byte[] bytes = super.asBytes(bitsCount);

    int currentBitIndex = super.getBitsCount();

    ByteUtils.addByteArrayToArrayAtByteIndex(leavingPeerInfo.asBytes(), bytes, currentBitIndex / 8);
    currentBitIndex += leavingPeerInfo.getBitsCount();

    for (ResourceObject currentResource : resources) {
      ByteUtils.addByteArrayToArrayAtByteIndex(
          currentResource.asBytes(), bytes, currentBitIndex / 8);
      currentBitIndex += currentResource.getBitsCount();
    }

    return bytes;
  }
Ejemplo n.º 4
0
  @Override
  protected byte[] asBytes(int bitsCount) {
    byte[] bytes = super.asBytes(bitsCount);

    int currentIndex = super.getBitsCount() / 8;

    ByteUtils.addByteArrayToArrayAtByteIndex(
        this.originatorPeerInfo.asBytes(), bytes, currentIndex);
    currentIndex += this.originatorPeerInfo.getBitsCount() / 8;

    for (PeerInfo currentPeerInfo : this.vset) {
      if (currentPeerInfo != null) {
        ByteUtils.addByteArrayToArrayAtByteIndex(currentPeerInfo.asBytes(), bytes, currentIndex);
        currentIndex += currentPeerInfo.getBitsCount() / 8;
      }
    }

    return bytes;
  }