@Override public int getBitsCount() { int additionalBits = 0; for (ResourceObject currentResource : resources) { additionalBits += currentResource.getBitsCount(); } return super.getBitsCount() + leavingPeerInfo.getBitsCount() + additionalBits; }
@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; }
@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; }
@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; }