Java Code Examples for com.google.protobuf.ExtensionRegistry#add()
The following examples show how to use
com.google.protobuf.ExtensionRegistry#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleBidRequest.java From bidder with Apache License 2.0 | 7 votes |
/** * Given the input stream, parse and make the class. * * @param in InputStream. The content of the POST * @throws Exception on protobuf, json or I/O errors. */ public GoogleBidRequest(InputStream in) throws Exception { int nRead; byte[] data = new byte[1024]; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); while ((nRead = in.read(data, 0, data.length)) != -1) { buffer.write(data, 0, nRead); } data = buffer.toByteArray(); if (data.length == 0) { notABidRequest = true; return; } ExtensionRegistry registry = ExtensionRegistry.newInstance(); registry.add(com.google.doubleclick.AdxExt.imp); internal = com.google.openrtb.OpenRtb.BidRequest.parseFrom(data, registry); // internal = com.google.openrtb.OpenRtb.BidRequest.parseFrom(in); doInternal(); }
Example 2
Source File: TestExtensionRegistry.java From jackson-datatype-protobuf with Apache License 2.0 | 6 votes |
public static ExtensionRegistry getInstance() { ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance(); Iterable<FieldDescriptor> extensionDescriptors = Iterables.concat( AllExtensions.getDescriptor().getExtensions(), RepeatedExtensions.getDescriptor().getExtensions() ); for (FieldDescriptor extension : extensionDescriptors) { if (extension.getJavaType() == JavaType.MESSAGE) { extensionRegistry.add(extension, Nested.getDefaultInstance()); } else { extensionRegistry.add(extension); } } return extensionRegistry; }
Example 3
Source File: ProtobufProcessMarshaller.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public void init(MarshallerReaderContext context) { ExtensionRegistry registry = (ExtensionRegistry) context.parameterObject; registry.add( JBPMMessages.processInstance ); registry.add( JBPMMessages.processTimer ); registry.add( JBPMMessages.procTimer ); registry.add( JBPMMessages.workItem ); registry.add( JBPMMessages.timerId ); }
Example 4
Source File: ProtobufTestUtil.java From datacollector with Apache License 2.0 | 5 votes |
public static ExtensionRegistry createExtensionRegistry(Map<String, Set<Descriptors.FieldDescriptor>> extensionMap) { ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance(); for(Map.Entry<String, Set<Descriptors.FieldDescriptor>> e : extensionMap.entrySet()) { Set<Descriptors.FieldDescriptor> value = e.getValue(); for (Descriptors.FieldDescriptor f : value) { extensionRegistry.add(f); } } return extensionRegistry; }
Example 5
Source File: CompatibilityTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testMergeAndParseFromInputStream() throws Exception { ExtensionRegistry registry = ExtensionRegistry.newInstance(); registry.add(Typical.myPrimitiveExtension); byte[] rawData = asBytes(new int[]{ 0x08, 0x06, 0x60, 0x01, 0x7A, 0x03, 0x62, 0x61, 0x72, 0xC8, 0x3E, 0x2D }); checkMergeAndParse( TypicalData.newBuilder().mergeFrom(new ByteArrayInputStream(rawData), registry).build(), true); checkMergeAndParse(TypicalData.parseFrom(new ByteArrayInputStream(rawData), registry), true); // test API without ExtensionRegistry checkMergeAndParse( TypicalData.newBuilder().mergeFrom(new ByteArrayInputStream(rawData)).build(), false); checkMergeAndParse(TypicalData.parseFrom(new ByteArrayInputStream(rawData)), false); }
Example 6
Source File: CompatibilityTest.java From j2objc with Apache License 2.0 | 5 votes |
public void testExtensionRegistryGetUnmodifiable() throws Exception { ExtensionRegistry registry = ExtensionRegistry.newInstance(); ExtensionRegistry registry2 = registry.getUnmodifiable(); registry.add(Typical.myPrimitiveExtension); // Extension added to registry should be visible in registry2. Descriptor descriptor = TypicalData.getDescriptor(); ExtensionRegistry.ExtensionInfo extensionInfo = registry2.findExtensionByNumber(descriptor, 1001); assertNotNull(extensionInfo); ExtensionRegistryLite registryLite = ExtensionRegistryLite.newInstance(); ExtensionRegistryLite registryLite2 = registryLite.getUnmodifiable(); assertNotNull(registryLite2); }
Example 7
Source File: OlapPipelineFactory.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private ExtensionRegistry buildExtensionRegistry(){ ExtensionRegistry er = ExtensionRegistry.newInstance(); er.add(OlapMessage.Submit.command); er.add(OlapMessage.Status.command); er.add(OlapMessage.Cancel.command); return er; }
Example 8
Source File: AsyncOlapNIOLayer.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private ExtensionRegistry buildExtensionRegistry(){ ExtensionRegistry er=ExtensionRegistry.newInstance(); er.add(OlapMessage.FailedResponse.response); er.add(OlapMessage.CancelledResponse.response); er.add(OlapMessage.ProgressResponse.response); er.add(OlapMessage.Result.response); return er; }