use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString in project compiler by boalang.
the class JsonFormat method printUnknownFields.
protected static void printUnknownFields(UnknownFieldSet unknownFields, JsonGenerator generator) throws IOException {
boolean firstField = true;
for (Map.Entry<Integer, UnknownFieldSet.Field> entry : unknownFields.asMap().entrySet()) {
UnknownFieldSet.Field field = entry.getValue();
if (firstField) {
firstField = false;
} else {
generator.print(", ");
}
generator.print("\"");
generator.print(entry.getKey().toString());
generator.print("\"");
generator.print(": [");
boolean firstValue = true;
for (long value : field.getVarintList()) {
if (firstValue) {
firstValue = false;
} else {
generator.print(", ");
}
generator.print(unsignedToString(value));
}
for (int value : field.getFixed32List()) {
if (firstValue) {
firstValue = false;
} else {
generator.print(", ");
}
generator.print(String.format((Locale) null, "0x%08x", value));
}
for (long value : field.getFixed64List()) {
if (firstValue) {
firstValue = false;
} else {
generator.print(", ");
}
generator.print(String.format((Locale) null, "0x%016x", value));
}
for (ByteString value : field.getLengthDelimitedList()) {
if (firstValue) {
firstValue = false;
} else {
generator.print(", ");
}
generator.print("\"");
generator.print(escapeBytes(value));
generator.print("\"");
}
for (UnknownFieldSet value : field.getGroupList()) {
if (firstValue) {
firstValue = false;
} else {
generator.print(", ");
}
generator.print("{\n");
printUnknownFields(value, generator);
generator.print("}\n");
}
generator.print("]");
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.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.v1p43p2.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.v1p43p2.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.v1p43p2.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());
}
Aggregations