Tabnine Logo
Schema.writeTo
Code IndexAdd Tabnine to your IDE (free)

How to use
writeTo
method
in
io.protostuff.Schema

Best Java code snippets using io.protostuff.Schema.writeTo (Showing top 20 results out of 315)

origin: protostuff/protostuff

@Override
public void writeTo(Output output, T message) throws IOException
{
  schema.writeTo(output, message);
}
origin: protostuff/protostuff

/**
 * Serializes the {@code message} into a JsonGenerator using the given {@code schema}.
 */
public static <T> void writeTo(JsonGenerator generator, T message, Schema<T> schema,
    boolean numeric) throws IOException
{
  generator.writeStartObject();
  final JsonOutput output = new JsonOutput(generator, numeric, schema);
  schema.writeTo(output, message);
  if (output.isLastRepeated())
    generator.writeEndArray();
  generator.writeEndObject();
}
origin: protostuff/protostuff

/**
 * Serializes the {@code message} into an {@link XMLStreamWriter} using the given {@code schema}.
 */
public static <T> void writeTo(XMLStreamWriter writer, T message, Schema<T> schema)
    throws IOException, XMLStreamException, XmlOutputException
{
  writer.writeStartElement(schema.messageName());
  schema.writeTo(new XmlOutput(writer, schema), message);
  writer.writeEndElement();
}
origin: protostuff/protostuff

/**
 * Serializes the {@code message} into an {@link OutputStream} using the given schema.
 * 
 * @return the size of the message
 */
public static <T> int writeTo(OutputStream out, T message, Schema<T> schema,
    LinkedBuffer buffer) throws IOException
{
  if (buffer.start != buffer.offset)
    throw new IllegalArgumentException("Buffer previously used and had not been reset.");
  final ProtobufOutput output = new ProtobufOutput(buffer);
  schema.writeTo(output, message);
  return LinkedBuffer.writeTo(out, buffer);
}
origin: protostuff/protostuff

@SuppressWarnings("unchecked")
static void writeObjectTo(Output output, Object value,
    Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
  final Schema<Object> schema = strategy.writePojoIdTo(output,
      ID_POJO, (Class<Object>) value.getClass()).getSchema();
  
  if (output instanceof StatefulOutput)
  {
    // update using the derived schema.
    ((StatefulOutput) output).updateLast(schema, currentSchema);
  }
  
  schema.writeTo(output, value);
}

origin: fengjiachun/Jupiter

@SuppressWarnings("unchecked")
@Override
public <T> OutputBuf writeObject(OutputBuf outputBuf, T obj) {
  Schema<T> schema = RuntimeSchema.getSchema((Class<T>) obj.getClass());
  Output output = Outputs.getOutput(outputBuf);
  try {
    schema.writeTo(output, obj);
  } catch (IOException e) {
    ThrowUtil.throwException(e);
  }
  return outputBuf;
}
origin: fengjiachun/Jupiter

@SuppressWarnings("unchecked")
@Override
public <T> OutputBuf writeObject(OutputBuf outputBuf, T obj) {
  Schema<T> schema = RuntimeSchema.getSchema((Class<T>) obj.getClass());
  Output output = Outputs.getOutput(outputBuf);
  try {
    schema.writeTo(output, obj);
  } catch (IOException e) {
    ThrowUtil.throwException(e);
  }
  return outputBuf;
}
origin: protostuff/protostuff

@SuppressWarnings("unchecked")
static void writeObjectTo(Output output, Object value,
    Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
  final Schema<Object> schema = strategy.writePojoIdTo(output,
      ID_POJO, (Class<Object>) value.getClass()).getSchema();
  
  if (output instanceof StatefulOutput)
  {
    // update using the derived schema.
    ((StatefulOutput) output).updateLast(schema, currentSchema);
  }
  
  schema.writeTo(output, value);
}

origin: protostuff/protostuff

public static <T> void writeTo(MessagePacker packer, T message, Schema<T> schema, boolean numeric)
    throws IOException
{
  MsgpackGenerator generator = new MsgpackGenerator(numeric);
  MsgpackOutput output = new MsgpackOutput(generator, schema);
  schema.writeTo(output, message);
  generator.writeTo(packer);
}
origin: protostuff/protostuff

@SuppressWarnings("unchecked")
static void writeObjectTo(Output output, Object value,
    Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
  final Schema<Object> schema = strategy.writePojoIdTo(output,
      ID_THROWABLE, (Class<Object>) value.getClass()).getSchema();
  if (output instanceof StatefulOutput)
  {
    // update using the derived schema.
    ((StatefulOutput) output).updateLast(schema, currentSchema);
  }
  if (tryWriteWithoutCause(output, value, schema))
    return;
  schema.writeTo(output, value);
}
origin: protostuff/protostuff

@Override
public <T> void writeObject(final int fieldNumber, final T value, final Schema<T> schema,
    final boolean repeated) throws IOException
{
  buffer.writeVarInt32(makeTag(fieldNumber, WIRETYPE_START_GROUP));
  schema.writeTo(this, value);
  buffer.writeVarInt32(makeTag(fieldNumber, WIRETYPE_END_GROUP));
}
origin: fengjiachun/Jupiter

@Override
public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated) throws IOException {
  writeVarInt32(makeTag(fieldNumber, WIRETYPE_START_GROUP));
  schema.writeTo(this, value);
  writeVarInt32(makeTag(fieldNumber, WIRETYPE_END_GROUP));
}
origin: fengjiachun/Jupiter

@Override
public <T> void writeObject(int fieldNumber, T value, Schema<T> schema, boolean repeated) throws IOException {
  writeVarInt32(makeTag(fieldNumber, WIRETYPE_START_GROUP));
  schema.writeTo(this, value);
  writeVarInt32(makeTag(fieldNumber, WIRETYPE_END_GROUP));
}
origin: protostuff/protostuff

@Override
public <T> void writeObject(final int fieldNumber, final T value, final Schema<T> schema,
    final boolean repeated) throws IOException
{
  tail = sink.writeVarInt32(
      makeTag(fieldNumber, WIRETYPE_START_GROUP),
      this,
      tail);
  schema.writeTo(this, value);
  tail = sink.writeVarInt32(
      makeTag(fieldNumber, WIRETYPE_END_GROUP),
      this,
      tail);
}
origin: protostuff/protostuff

/**
 * Serializes the {@code messages} into the generator using the given schema.
 */
public static <T> void writeListTo(MessagePacker packer, List<T> messages,
    Schema<T> schema, boolean numeric) throws IOException
{
  MsgpackGenerator generator = new MsgpackGenerator(numeric);
  MsgpackOutput output = new MsgpackOutput(generator, schema);
  for (T m : messages)
  {
    schema.writeTo(output, m);
    generator.writeTo(packer);
    generator.reset();
  }
}
origin: protostuff/protostuff

/**
 * Write the nested message encoded as group.
 */
<T> void writeObjectEncodedAsGroup(final int fieldNumber, final T value, final Schema<T> schema,
    boolean repeated) throws IOException
{
  writeTag(fieldNumber, WireFormat.WIRETYPE_START_GROUP);
  schema.writeTo(this, value);
  writeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP);
}
origin: protostuff/protostuff

@Override
public <T> void writeObject(int fieldNumber, T value, Schema<T> innerSchema, boolean repeated) throws IOException
{
  MsgpackGenerator innerGenerator = new MsgpackGenerator(generator.isNumeric());
  MsgpackGenerator thisGenerator = this.generator;
  Schema<?> thisSchema = this.schema;
  use(innerGenerator, innerSchema);
  innerSchema.writeTo(this, value);
  use(thisGenerator, thisSchema);
  generator.pushValue(this.schema, fieldNumber, innerGenerator.toValue(), repeated);
}
origin: protostuff/protostuff

@Override
protected <T> void writeDelimitedTo(OutputStream out, T message, Schema<T> schema)
    throws IOException
{
  final ComputedSizeOutput sizeCount = new ComputedSizeOutput(false);
  schema.writeTo(sizeCount, message);
  CodedOutput.writeRawVarInt32Bytes(out, sizeCount.getSize());
  final CodedOutput output = CodedOutput.newInstance(out);
  schema.writeTo(output, message);
  output.flush();
}
origin: protostuff/protostuff

static <T> byte[] toByteArrayBufferedProtostuff(T message, Schema<T> schema)
{
  final ProtostuffOutput output = new ProtostuffOutput(new LinkedBuffer(BUF_SIZE));
  try
  {
    schema.writeTo(output, message);
  }
  catch (IOException e)
  {
    throw new RuntimeException("Serializing to a byte array threw an IOException " +
        "(should never happen).", e);
  }
  return output.toByteArray();
}
origin: protostuff/protostuff

<T> void writeObjectEncodedAsGroup(int fieldNumber, T value, Schema<T> schema,
    boolean repeated) throws IOException
{
  size += ProtobufOutput.computeRawVarint32Size(WireFormat.makeTag(fieldNumber,
      WireFormat.WIRETYPE_START_GROUP));
  schema.writeTo(this, value);
  size += ProtobufOutput.computeRawVarint32Size(WireFormat.makeTag(fieldNumber,
      WireFormat.WIRETYPE_END_GROUP));
}
io.protostuffSchemawriteTo

Javadoc

Serializes a message/object to the Output.

Popular methods of Schema

  • newMessage
  • mergeFrom
  • isInitialized
  • getFieldName
  • typeClass
  • getFieldNumber
  • messageFullName
  • messageName
    Returns the simple name of the message tied to this schema. Allows custom schemas to provide a custo

Popular in Java

  • Making http post requests using okhttp
  • addToBackStack (FragmentTransaction)
  • getSystemService (Context)
  • putExtra (Intent)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • JButton (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now