gpt4 book ai didi

com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 04:00:40 28 4
gpt4 key购买 nike

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

YAMLFactory.createGenerator介绍

暂无

代码示例

代码示例来源:origin: HubSpot/Singularity

@Override
public InputStream open(String path) throws IOException {
  final JsonNode originalNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(defaultConfigurationPath)));
  final JsonNode overrideNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(path)));
  if (!(originalNode instanceof ObjectNode && overrideNode instanceof ObjectNode)) {
    throw new SingularityConfigurationMergeException(String.format("Both %s and %s need to be YAML objects", defaultConfigurationPath, path));
  }
  merge((ObjectNode)originalNode, (ObjectNode)overrideNode);
  final ByteArrayOutputStream baos = new ByteArrayOutputStream();
  objectMapper.writeTree(yamlFactory.createGenerator(baos), originalNode);
  return new ByteArrayInputStream(baos.toByteArray());
}

代码示例来源:origin: stackoverflow.com

YAMLFactory yf = new YAMLFactory();
ObjectMapper mapper = new ObjectMapper(yf);
ObjectNode root = (ObjectNode) mapper.readTree(yamlFileIn);
// modify root here     
FileOutputStream fos = new FileOutputStream(yamlFileOut);
yf.createGenerator(fos).writeObject(root); // works. yay.

代码示例来源:origin: io.digdag/digdag-cli

public <T> void writeFile(File file, T value)
  throws IOException
{
  file.getParentFile().mkdirs();
  // TODO use yaml if file path ends with dig or yml, otherwise use json?
  try (YAMLGenerator out = yaml.createGenerator(new FileOutputStream(file))) {
    // TODO write to a String first, then write to file. to not create partially-written broken file
    mapper.writeValue(out, value);
  }
}

代码示例来源:origin: io.digdag/digdag-cli

public <T> String toYaml(T value)
{
  try {
    StringWriter writer = new StringWriter();
    try (YAMLGenerator out = yaml.createGenerator(writer)) {
      mapper.writeValue(out, value);
    }
    return writer.toString();
  }
  catch (IOException ex) {
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

@Override
public XContentGenerator createGenerator(OutputStream os, Set<String> includes, Set<String> excludes) throws IOException {
  return new YamlXContentGenerator(yamlFactory.createGenerator(os, JsonEncoding.UTF8), os, includes, excludes);
}

代码示例来源:origin: org.seedstack.seed/seed-core

void writeDiagnosticReport(Map<String, Object> diagnosticInfo, Writer writer) throws IOException {
    try (JsonGenerator jsonGenerator = YAML_FACTORY.createGenerator(writer)) {
      jsonGenerator.setPrettyPrinter(DEFAULT_PRETTY_PRINTER);
      jsonGenerator.writeObject(diagnosticInfo);
      jsonGenerator.flush();
    }
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch-x-content

@Override
public XContentGenerator createGenerator(OutputStream os, Set<String> includes, Set<String> excludes) throws IOException {
  return new YamlXContentGenerator(yamlFactory.createGenerator(os, JsonEncoding.UTF8), os, includes, excludes);
}

代码示例来源:origin: org.codelibs/elasticsearch-querybuilders

@Override
public XContentGenerator createGenerator(OutputStream os, Set<String> includes, Set<String> excludes) throws IOException {
  return new YamlXContentGenerator(yamlFactory.createGenerator(os, JsonEncoding.UTF8), os, includes, excludes);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public XContentGenerator createGenerator(OutputStream os, Set<String> includes, Set<String> excludes) throws IOException {
  return new YamlXContentGenerator(yamlFactory.createGenerator(os, JsonEncoding.UTF8), os, includes, excludes);
}

代码示例来源:origin: jillesvangurp/jsonj

public void serialize(Writer w, JsonElement e) {
  try {
    YAMLGenerator yaml = factory.createGenerator(w);
    serialize(yaml, e);
    yaml.flush();
  } catch (IOException e1) {
    throw new IllegalStateException(e1);
  }
}

代码示例来源:origin: codehaus-cargo/cargo

/**
   * Creates YAML generator instance.
   * @return YAMLGenerator instance.
   */
  private YAMLGenerator createYamlGenerator()
  {
    final Writer writer = new StringWriter();

    YAMLFactory yamlFactory = new YAMLFactory();
    yamlFactory.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true);
    yamlFactory.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER);

    try
    {
      return yamlFactory.createGenerator(writer);
    }
    catch (IOException ex)
    {
      throw new RuntimeException("Cannot create YAML generator.", ex);
    }
  }
}

代码示例来源:origin: com.hubspot/SingularityService

@Override
public InputStream open(String path) throws IOException {
  final JsonNode originalNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(defaultConfigurationPath)));
  final JsonNode overrideNode = objectMapper.readTree(yamlFactory.createParser(delegate.open(path)));
  if (!(originalNode instanceof ObjectNode && overrideNode instanceof ObjectNode)) {
    throw new SingularityConfigurationMergeException(String.format("Both %s and %s need to be YAML objects", defaultConfigurationPath, path));
  }
  merge((ObjectNode)originalNode, (ObjectNode)overrideNode);
  final ByteArrayOutputStream baos = new ByteArrayOutputStream();
  objectMapper.writeTree(yamlFactory.createGenerator(baos), originalNode);
  return new ByteArrayInputStream(baos.toByteArray());
}

代码示例来源:origin: io.digdag/digdag-standards

try (YAMLGenerator out = yaml.createGenerator(workspace.newOutputStream(tempFile), JsonEncoding.UTF8)) {
  mapper.writeValue(out, embulkConfig);

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