/** {@inheritDoc} */ @Override public void cellValue(ByteString value) { this.value = this.value.concat(value); }
private static ByteString balancedConcat(Iterator<ByteString> iterator, int length) { if (length < 1) { throw new IllegalArgumentException(String.format("length (%s) must be >= 1", length)); } ByteString result; if (length == 1) { result = iterator.next(); } else { int halfLength = length >>> 1; ByteString left = balancedConcat(iterator, halfLength); ByteString right = balancedConcat(iterator, length - halfLength); result = left.concat(right); } return result; }
private static ByteString balancedConcat(Iterator<ByteString> iterator, int length) { assert length >= 1; ByteString result; if (length == 1) { result = iterator.next(); } else { int halfLength = length >>> 1; ByteString left = balancedConcat(iterator, halfLength); ByteString right = balancedConcat(iterator, length - halfLength); result = left.concat(right); } return result; }
@Test public void lengthTest() { ByteString a = ByteString.copyFromUtf8("a"); ByteString a_ = ByteString.copyFromUtf8("b").concat(ByteString.copyFrom(new byte[] {0})); Truth.assertThat(ByteStringComparator.INSTANCE.compare(a, a_)).isEqualTo(-1); Truth.assertThat(ByteStringComparator.INSTANCE.compare(a_, a)).isEqualTo(1); } }
setByteString(this.delayedBytes.concat(input.readBytes()), this.extensionRegistry); return;
/** * Generates a payload of desired type and size. Reads compressableBuffer or * uncompressableBuffer as a circular buffer. */ private ByteString generatePayload(ByteString dataBuffer, int offset, int size) { ByteString payload = ByteString.EMPTY; // This offset would never pass the array boundary. int begin = offset; int end = 0; int bytesLeft = size; while (bytesLeft > 0) { end = Math.min(begin + bytesLeft, dataBuffer.size()); // ByteString.substring returns the substring from begin, inclusive, to end, exclusive. payload = payload.concat(dataBuffer.substring(begin, end)); bytesLeft -= (end - begin); begin = end % dataBuffer.size(); } return payload; }
public static ByteStringRange prefix(ByteString prefix) { if (prefix.isEmpty()) { return unbounded(); } int offset = prefix.size() - 1; int curByte = 0xFF; while (offset >= 0) { curByte = prefix.byteAt(offset) & 0xFF; if (curByte != 0xFF) { break; } offset--; } if (offset < 0) { // We got an 0xFFFF... (only FFs) stopRow value which is // the last possible prefix before the end of the table. // So set it to stop at the 'end of the table' return unbounded().startClosed(prefix); } ByteString endPrefix = offset == 0 ? ByteString.EMPTY : prefix.substring(0, offset); ByteString endSuffix = UnsafeByteOperations.unsafeWrap(new byte[] {(byte) (curByte + 1)}); ByteString end = endPrefix.concat(endSuffix); ByteStringRange range = ByteStringRange.unbounded().startClosed(prefix); if (!end.isEmpty()) { range.endOpen(end); } return range; }
this.delayedBytes = this.delayedBytes.concat(other.delayedBytes); return;
public ByteString signByteStrings(ByteString... bs) throws CryptoException, InvalidArgumentException { if (bs == null) { return null; } if (bs.length == 0) { return null; } if (bs.length == 1 && bs[0] == null) { return null; } ByteString f = bs[0]; for (int i = 1; i < bs.length; ++i) { f = f.concat(bs[i]); } return ByteString.copyFrom(sign(f.toByteArray())); }
public ByteString[] signByteStrings(User[] users, ByteString... bs) throws CryptoException, InvalidArgumentException { if (bs == null) { return null; } if (bs.length == 0) { return null; } if (bs.length == 1 && bs[0] == null) { return null; } ByteString f = bs[0]; for (int i = 1; i < bs.length; ++i) { f = f.concat(bs[i]); } final byte[] signbytes = f.toByteArray(); ByteString[] ret = new ByteString[users.length]; int i = -1; for (User user : users) { // Get the signing identity from the user SigningIdentity signingIdentity = IdentityFactory.getSigningIdentity(cryptoPrimitives, user); // generate signature ret[++i] = ByteString.copyFrom(signingIdentity.sign(signbytes)); } return ret; }
public TransactionContext(Channel channel, User user, CryptoSuite cryptoPrimitives) { this.user = user; this.channel = channel; //TODO clean up when public classes are interfaces. this.verify = !"".equals(channel.getName()); //if name is not blank not system channel and need verify. // this.txID = transactionID; this.cryptoPrimitives = cryptoPrimitives; // Get the signing identity from the user this.signingIdentity = IdentityFactory.getSigningIdentity(cryptoPrimitives, user); // Serialize signingIdentity this.identity = signingIdentity.createSerializedIdentity(); ByteString no = getNonce(); ByteString comp = no.concat(identity.toByteString()); byte[] txh = cryptoPrimitives.hash(comp.toByteArray()); // txID = Hex.encodeHexString(txh); txID = new String(Utils.toHexString(txh)); toString = "TransactionContext{ txID: " + txID + ", mspid: " + user.getMspId() + ", user: " + user.getName() + "}"; }
Identities.SerializedIdentity endorser = Identities.SerializedIdentity .parseFrom(endorsement.getEndorser()); ByteString plainText = proposalResponse.getPayload().concat(endorsement.getEndorser());
/** {@inheritDoc} */ @Override public void cellValue(ByteString value) { this.value = this.value.concat(value); }
public void merge(LazyFieldLite value) { if (value.containsDefaultInstance()) { return; } if (bytes == null) { this.bytes = value.bytes; } else { this.bytes.concat(value.toByteString()); } isDirty = false; }
public Builder mergeFrom(protobuf_unittest.NestedExtensionLite.MyNestedExtensionLite other) { if (other == protobuf_unittest.NestedExtensionLite.MyNestedExtensionLite.getDefaultInstance()) return this; setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; }
public Builder mergeFrom(com.google.protobuf.UnittestLite.TestAllExtensionsLite other) { if (other == com.google.protobuf.UnittestLite.TestAllExtensionsLite.getDefaultInstance()) return this; this.mergeExtensionFields(other); setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; }
public Builder mergeFrom(protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Bar other) { if (other == protobuf_unittest.lite_equals_and_hash.LiteEqualsAndHash.Bar.getDefaultInstance()) return this; if (other.hasName()) { bitField0_ |= 0x00000001; name_ = other.name_; } setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; }
public Builder mergeFrom(com.google.protobuf.UnittestLite.ForeignMessageLite other) { if (other == com.google.protobuf.UnittestLite.ForeignMessageLite.getDefaultInstance()) return this; if (other.hasC()) { setC(other.getC()); } setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; }
public Builder mergeFrom(com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup other) { if (other == com.google.protobuf.UnittestLite.TestAllTypesLite.RepeatedGroup.getDefaultInstance()) return this; if (other.hasA()) { setA(other.getA()); } setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; }
public Builder mergeFrom(LspMon.lsp_monitor_data_event other) { if (other == LspMon.lsp_monitor_data_event.getDefaultInstance()) return this; if (other.hasEventIdentifier()) { setEventIdentifier(other.getEventIdentifier()); } if (other.hasSubcode()) { setSubcode(other.getSubcode()); } setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; }