Search in sources :

Example 36 with ByteString

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("]");
    }
}
Also used : BigInteger(java.math.BigInteger) Locale(java.util.Locale) ByteString(com.google.protobuf.ByteString) Map(java.util.Map) UnknownFieldSet(com.google.protobuf.UnknownFieldSet)

Example 37 with ByteString

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);
}
Also used : ByteString(com.google.protobuf.ByteString)

Example 38 with ByteString

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);
}
Also used : ByteString(com.google.protobuf.ByteString)

Example 39 with ByteString

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);
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 40 with ByteString

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());
}
Also used : ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

ByteString (com.google.protobuf.ByteString)406 Test (org.junit.Test)143 ArrayList (java.util.ArrayList)65 ByteString (org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.ByteString)63 HashMap (java.util.HashMap)41 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)40 IOException (java.io.IOException)37 List (java.util.List)33 Map (java.util.Map)33 ServerRequest (com.pokegoapi.main.ServerRequest)17 ExecutionException (java.util.concurrent.ExecutionException)16 AnnotateImageRequest (com.google.cloud.vision.v1.AnnotateImageRequest)14 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)14 BatchAnnotateImagesResponse (com.google.cloud.vision.v1.BatchAnnotateImagesResponse)14 Feature (com.google.cloud.vision.v1.Feature)14 Image (com.google.cloud.vision.v1.Image)14 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)14 FileInputStream (java.io.FileInputStream)13 ByteBuffer (java.nio.ByteBuffer)13 WebImage (com.google.cloud.vision.v1.WebDetection.WebImage)12