Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }