gpt4 book ai didi

io.protostuff.YamlIOUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 16:23:31 24 4
gpt4 key购买 nike

本文整理了Java中io.protostuff.YamlIOUtil类的一些代码示例,展示了YamlIOUtil类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlIOUtil类的具体详情如下:
包路径:io.protostuff.YamlIOUtil
类名称:YamlIOUtil

YamlIOUtil介绍

[英]Utility for the YAML serialization of messages and objects tied to a schema.
[中]用于对绑定到模式的消息和对象进行YAML序列化的实用程序。

代码示例

代码示例来源:origin: protostuff/protostuff

public <T> int writeTo(OutputStream out, T message, Schema<T> schema) throws IOException
{
  return YamlIOUtil.writeTo(out, message, schema, buf());
}

代码示例来源:origin: protostuff/protostuff

public <T> byte[] toByteArray(T message, Schema<T> schema)
{
  return YamlIOUtil.toByteArray(message, schema, buf());
}

代码示例来源:origin: protostuff/protostuff

public <T> int writeListTo(LinkedBuffer buffer, List<T> messages, Schema<T> schema)
    throws IOException
{
  return YamlIOUtil.writeListTo(buffer, messages, schema);
}

代码示例来源:origin: protostuff/protostuff

@Override
public <T extends Message<T>> byte[] serialize(T message)
{
  try
  {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    YamlIOUtil.writeTo(out, message, message.cachedSchema(), buffer);
    return out.toByteArray();
  }
  catch (IOException e)
  {
    throw new RuntimeException(e);
  }
  finally
  {
    buffer.clear();
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
public <T extends Message<T>> byte[] serialize(T message)
{
  try
  {
    return YamlIOUtil.toByteArray(message, message.cachedSchema(), buffer);
  }
  finally
  {
    buffer.clear();
  }
}

代码示例来源:origin: protostuff/protostuff

public <T> int writeListTo(OutputStream out, List<T> messages, Schema<T> schema)
    throws IOException
{
  return YamlIOUtil.writeListTo(out, messages, schema, buf());
}

代码示例来源:origin: NationalSecurityAgency/datawave

XmlIOUtil.writeTo(out, message, schema);
} else if ("text/yaml".equals(media.toString()) || "text/x-yaml".equals(media.toString()) || "application/x-yaml".equals(media.toString())) {
  YamlIOUtil.writeTo(out, message, schema, buffer);
} else if ("application/x-protobuf".equals(media.toString())) {
  ProtobufIOUtil.writeTo(out, message, schema, buffer);

代码示例来源:origin: protostuff/protostuff

static <T> void protobufRoundTrip(T message, Schema<T> schema,
    Pipe.Schema<T> pipeSchema) throws Exception
{
  byte[] protobuf = ProtobufIOUtil.toByteArray(message, schema, buf());
  ByteArrayInputStream protobufStream = new ByteArrayInputStream(protobuf);
  byte[] yaml = YamlIOUtil.toByteArray(
      ProtobufIOUtil.newPipe(protobuf, 0, protobuf.length), pipeSchema, buf());
  byte[] yamlFromStream = YamlIOUtil.toByteArray(
      ProtobufIOUtil.newPipe(protobufStream), pipeSchema, buf());
  assertTrue(yaml.length == yamlFromStream.length);
  String strYaml = STRING.deser(yaml);
  String strYamlFromStream = STRING.deser(yamlFromStream);
  assertEquals(strYaml, strYamlFromStream);
}

代码示例来源:origin: NationalSecurityAgency/datawave

Message<Object> yaml = (Message<Object>) page;
Schema<Object> yamlSchema = yaml.cachedSchema();
YamlIOUtil.writeTo(countingStream, page, yamlSchema, buffer);
buffer.clear();
break;

代码示例来源:origin: protostuff/protostuff

static <T> void protostuffRoundTrip(T message, Schema<T> schema,
    Pipe.Schema<T> pipeSchema) throws Exception
{
  byte[] protostuff = ProtostuffIOUtil.toByteArray(message, schema, buf());
  ByteArrayInputStream protostuffStream = new ByteArrayInputStream(protostuff);
  byte[] yaml = YamlIOUtil.toByteArray(
      ProtostuffIOUtil.newPipe(protostuff, 0, protostuff.length), pipeSchema, buf());
  byte[] yamlFromStream = YamlIOUtil.toByteArray(
      ProtostuffIOUtil.newPipe(protostuffStream), pipeSchema, buf());
  assertTrue(yaml.length == yamlFromStream.length);
  String strYaml = STRING.deser(yaml);
  String strYamlFromStream = STRING.deser(yamlFromStream);
  assertEquals(strYaml, strYamlFromStream);
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com