Merges the {@code message} with the byte array using the given {@code schema}.
974667
static <T> void mergeFrom(byte[] data, int offset, int length, T message,
            Schema<T> schema, boolean decodeNestedMessageAsGroup)
    {
        try
        {
            final ByteArrayInput input = new ByteArrayInput(data, offset, length,
                    decodeNestedMessageAsGroup);
            schema.mergeFrom(input, message);
            input.checkLastTagWas(0);
        }
        catch (ArrayIndexOutOfBoundsException ae)
        {
            throw new RuntimeException("Truncated.", ProtobufException.truncatedMessage(ae));
        }
        catch (IOException e)
        {
            throw new RuntimeException("Reading from a byte array threw an IOException (should " +
                    "never happen).", e);
        }
    }
98899
public SingleFieldBuilder<MType, BType, IType> setMessage(
      MType message) {
    if (message == null) {
      throw new NullPointerException();
    }
    this.message = message;
    if (builder != null) {
      builder.dispose();
      builder = null;
    }
    onChanged();
    return this;
  }
495226
public DataWriterBuilder<S, D> withSchema(S schema) {
    this.schema = schema;
    log.debug("withSchema : {}", this.schema);
    return this;
  }
873897
public SchemaRepositoryModelBuilder addSchema(SchemaModel schema) {
        if (model.getSchemas() == null) {
            model.setSchemas(new SchemaRepositoryModel.Schemas());
        }

        model.getSchemas().getSchemas().add(schema);
        return this;
    }
1316126
public static <T> void writeListTo(OutputStream out, List<T> messages, 
            Schema<T> schema, boolean numeric) throws IOException
    {
        final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), 
                out, false);
        
        final JsonGenerator generator = newJsonGenerator(out, 
                context.allocWriteEncodingBuffer(), 0, true, context);
        /*final JsonGenerator generator = DEFAULT_JSON_FACTORY.createJsonGenerator(out, 
                JsonEncoding.UTF8);*/
        try
        {
            writeListTo(generator, messages, schema, numeric);
        }
        finally
        {
            generator.close();
        }
    }
138214
public static <T> void mergeFrom(InputStream in, T message, Schema<T> schema,
            XMLInputFactory inFactory) throws IOException
    {
        XMLStreamReader parser = null;
        try
        {
            parser = inFactory.createXMLStreamReader(in, XML_ENCODING);
            mergeFrom(parser, message, schema);
        }
        catch (XMLStreamException e)
        {
            throw new XmlInputException(e);
        }
        finally
        {
            if (parser != null)
            {
                try
                {
                    parser.close();
                }
                catch (XMLStreamException e)
                {
                    // ignore
                }
            }
        }
    }
1368010
public static <T> byte[] toByteArray(T message, Schema<T> schema, LinkedBuffer buffer)
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        final XmlXOutput output = new XmlXOutput(buffer, schema);

        final String name = schema.messageName();
        try
        {
            // header and start root element
            output.tail = output.sink.writeByte(XmlXOutput.END_TAG, output,
                    output.sink.writeStrAscii(name, output,
                            output.sink.writeByte(XmlXOutput.START_TAG, output,
                                    output.sink.writeByteArray(HEADER, output, output.tail))));

            schema.writeTo(output, message);

            // end root element
            output.tail = output.sink.writeByte(XmlXOutput.END_TAG, output,
                    output.sink.writeStrAscii(name, output,
                            output.sink.writeByteArray(XmlXOutput.START_SLASH_TAG, output, output.tail)));
        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }

        return output.toByteArray();
    }
300747
public static <T> void writeTo(OutputStream out, T message, Schema<T> schema, boolean numeric,
            LinkedBuffer buffer) throws IOException
    {
        if (buffer.start != buffer.offset)
        {
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");
        }

        MsgpackXOutput output = new MsgpackXOutput(buffer, numeric, schema);

        LinkedBuffer objectHeader = output.writeStartObject();
        schema.writeTo(output, message);

        if (output.isLastRepeated())
        {
            output.writeEndArray();
        }

        output.writeEndObject(objectHeader);

        LinkedBuffer.writeTo(out, buffer);
    }
949190
public static <T> void mergeFrom(XMLStreamReader parser, T message, Schema<T> schema)
            throws IOException, XMLStreamException, XmlInputException
    {
        // final String simpleName = schema.messageName();

        if (parser.nextTag() != START_ELEMENT ||
                !schema.messageName().equals(parser.getLocalName()))
        {
            throw new XmlInputException("Expected token START_ELEMENT: " + schema.messageName());
        }

        if (parser.nextTag() == END_ELEMENT)
        {
            // if(!simpleName.equals(parser.getLocalName()))
            // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);

            // empty message;
            return;
        }

        schema.mergeFrom(new XmlInput(parser), message);

        // if(!simpleName.equals(parser.getLocalName()))
        // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);
    }
1239015
function merge (schema, doc, self) {
  var keys = Object.keys(doc);

  for (var i = 0; i < keys.length; ++i) {
    var key = keys[i];
    var type;

    // if nothing in schema yet, just assign
    if ('undefined' == typeof schema[key]) {
      var type = self.getType(doc, key);
      if (undefined !== type) {
        schema[key] = type;
      }
      continue;
    }

    // exists in schema and incoming is an object?
    if (isObject(doc[key])) {
      if (isObject(schema[key])) {
        merge(schema[key], doc[key], self);

      } else {
        type = self.getType(doc, key);
        if (undefined !== type) {
          if ('null' == schema[key]) {
            schema[key] = type;
          } else if (type != schema[key]) {
            schema[key] = 'Mixed';
          }
        }
      }
    } else {
      // exists in schema and incoming is not an object.
      var type = self.getType(doc, key);
      if (undefined === type) {
        continue;
      }

      if ('null' == schema[key]) {
        schema[key] = type;

      } else if ('null' == type) {
        // ignore

      } else if (Array.isArray(schema[key]) && Array.isArray(type)) {

        if (0 === schema[key].length) {
          schema[key] = type;

        } else if (schema[key][0] instanceof Schema && isObject(type[0])) {
          // merge schemas
          schema[key][0].combine(type[0]);

        } else if (!equalType(schema[key], type)) {
          schema[key] = ['Mixed'];
        }

      } else if (!equalType(schema[key], type)) {
        schema[key] = 'Mixed';
      }
    }
  }
}
89571
public static <T> void writeListTo(LinkedBuffer buffer,
            List<T> messages, Schema<T> schema, boolean numeric)
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        if (messages.isEmpty())
        {
            System.arraycopy(EMPTY_ARRAY, 0, buffer.buffer, buffer.offset, EMPTY_ARRAY.length);
            buffer.offset += EMPTY_ARRAY.length;
            return;
        }

        final JsonXOutput output = new JsonXOutput(buffer, numeric, schema);

        try
        {
            output.writeStartArray();

            boolean first = true;
            for (T m : messages)
            {
                if (first)
                {
                    first = false;
                    output.writeStartObject();
                }
                else
                    output.writeCommaAndStartObject();

                schema.writeTo(output, m);
                if (output.isLastRepeated())
                    output.writeEndArray();

                output.writeEndObject().reset();
            }

            output.writeEndArray();
        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }
    }
597232
def merge!(schema)
      if schema.is_a?(Schema)
        @data.merge!(schema.data)
      else
        @data.merge!(schema)
      end
    end
65266
public static <T> byte[] toByteArray(T message, Schema<T> schema,
            XMLOutputFactory outFactory)
    {
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        try
        {
            writeTo(out, message, schema, outFactory);
        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a byte array threw an IOException " +
                    "(should never happen).", e);
        }
        return out.toByteArray();
    }
1121728
def add_schema(self, schema):
        

        # serialize instances of SchemaNode before parsing
        if isinstance(schema, SchemaNode):
            schema = schema.to_schema()

        for subschema in self._get_subschemas(schema):
            # delegate to SchemaType object
            schema_generator = self._get_generator_for_schema(subschema)
            schema_generator.add_schema(subschema)

        # return self for easy method chaining
        return self
981150
public static int mergeDelimitedFrom(InputStream in, Object message, Schema schema) 
    throws IOException
    {
        return IOUtil.mergeDelimitedFrom(in, message, schema, true);
    }
364641
public void mergeFrom(Input input, final Object owner) throws IOException
    {
        final int first = input.readFieldNumber(this);
        if(first != ID_POJO)
            throw new ProtostuffException("order not preserved.");
        
        doMergeFrom(input, 
                strategy.resolvePojoFrom(input, ID_POJO).getSchema(), 
                owner);
    }
1154664
public static <T> void writeTo(OutputStream out, T message, Schema<T> schema)
            throws IOException
    {
        writeTo(out, message, schema, DEFAULT_OUTPUT_FACTORY);
    }