use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method convertMacAddress.
private String convertMacAddress(final ByteString byteString) {
final StringBuilder stringBuilder = new StringBuilder();
for (final byte b : byteString.toByteArray()) {
stringBuilder.append(String.format("%02X", b)).append("-");
}
final String macAddress = stringBuilder.toString();
LOGGER.info("macAddress: {}", macAddress);
return macAddress.substring(0, macAddress.length() - 1);
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project Protocol-Adapter-OSLP by OSGP.
the class OslpGetConfigurationResponseToConfigurationConverter method convertIpAddress.
private String convertIpAddress(final ByteString byteString) {
if (byteString == null || byteString.isEmpty()) {
return "";
}
LOGGER.debug("byteString.toByteArray().length(): {}", byteString.toByteArray().length);
final StringBuilder stringBuilder = new StringBuilder();
for (final byte number : byteString.toByteArray()) {
int convertedNumber = number;
if (number < 0) {
convertedNumber = 256 + number;
}
final String str = String.valueOf(convertedNumber);
stringBuilder.append(str).append(".");
}
final String ipValue = stringBuilder.toString();
return ipValue.substring(0, ipValue.length() - 1);
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project core-java by SpineEventEngine.
the class Preconditions2Should method not_accept_empty_ByteString_value.
@Test(expected = IllegalArgumentException.class)
public void not_accept_empty_ByteString_value() {
final ByteString str = ByteString.EMPTY;
checkNewValueNotEmpty(str);
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project core-java by SpineEventEngine.
the class ChangesShould method create_byte_string_value_change.
@Test
public void create_byte_string_value_change() {
final ByteString previousValue = ByteString.copyFromUtf8(randomUuid());
final ByteString newValue = ByteString.copyFromUtf8(randomUuid());
final BytesChange result = Changes.of(previousValue, newValue);
assertEquals(previousValue, result.getPreviousValue());
assertEquals(newValue, result.getNewValue());
}
use of org.apache.beam.vendor.grpc.v1p26p0.com.google.protobuf.ByteString in project baseio by generallycloud.
the class Test method main.
public static void main(String[] args) throws InvalidProtocolBufferException {
ByteString byteString = ByteString.copyFrom("222".getBytes());
SearchRequest request = SearchRequest.newBuilder().setCorpus(Corpus.IMAGES).setPageNumber(100).setQuery("test").setQueryBytes(byteString).setResultPerPage(-1).build();
byte[] data = request.toByteArray();
SearchRequest r2 = SearchRequest.parseFrom(data);
System.out.println(r2.toString());
int i = 0b011111111111111111111111;
System.out.println(i);
}
Aggregations