当前位置: 首页>>代码示例>>Java>>正文


Java YAMLGenerator类代码示例

本文整理汇总了Java中com.fasterxml.jackson.dataformat.yaml.YAMLGenerator的典型用法代码示例。如果您正苦于以下问题:Java YAMLGenerator类的具体用法?Java YAMLGenerator怎么用?Java YAMLGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


YAMLGenerator类属于com.fasterxml.jackson.dataformat.yaml包,在下文中一共展示了YAMLGenerator类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createObjectMapper

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
public static ObjectMapper createObjectMapper() {
    final YAMLFactory yamlFactory = new YAMLFactory()
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
        .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
        .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);

    ObjectMapper mapper = new ObjectMapper(yamlFactory)
        .registerModule(new Jdk8Module())
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .enable(SerializationFeature.INDENT_OUTPUT)
        .disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
        mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
    }

    return mapper;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:20,代码来源:YamlHelpers.java

示例2: createObjectMapper

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
public static ObjectMapper createObjectMapper() {
    final YAMLFactory yamlFactory = new YAMLFactory()
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
        .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
        .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
        .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);

    ObjectMapper mapper = new ObjectMapper(yamlFactory)
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .enable(SerializationFeature.INDENT_OUTPUT)
        .disable(SerializationFeature.WRITE_NULL_MAP_VALUES);

    for (Step step : ServiceLoader.load(Step.class, YamlHelpers.class.getClassLoader())) {
        mapper.registerSubtypes(new NamedType(step.getClass(), step.getKind()));
    }

    return mapper;
}
 
开发者ID:syndesisio,项目名称:syndesis-integration-runtime,代码行数:19,代码来源:YamlHelpers.java

示例3: providesYamlMapper

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
@Provides
@Singleton
@Named(YAML)
public ObjectMapper providesYamlMapper() {
  final YAMLFactory yamlFactory = new YAMLFactory();
  yamlFactory.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER);

  final ObjectMapper mapper = new ObjectMapper(yamlFactory);
  mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  mapper.registerModule(new GuavaModule());
  mapper.registerModule(new ProtobufModule());

  return mapper;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:16,代码来源:SingularityRunnerBaseModule.java

示例4: createYamlMapper

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
public static ObjectMapper createYamlMapper() {
    ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()
            .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)
            .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true)
            .configure(YAMLGenerator.Feature.USE_NATIVE_OBJECT_ID, false)
            .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false)
    );
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY).
            enable(SerializationFeature.INDENT_OUTPUT).
            disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS).
            disable(SerializationFeature.WRITE_NULL_MAP_VALUES);
    return objectMapper;

}
 
开发者ID:funktionio,项目名称:funktion-connectors,代码行数:15,代码来源:YamlHelper.java

示例5: createJacksonGenerator

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
public YAMLGenerator createJacksonGenerator(StringWriter out) throws SchemaException{
	try {
		MidpointYAMLFactory factory = new MidpointYAMLFactory();
		MidpointYAMLGenerator generator = (MidpointYAMLGenerator) factory.createGenerator(out);
		generator.setPrettyPrinter(new DefaultPrettyPrinter());
		generator.setCodec(configureMapperForSerialization());
		return generator;
	} catch (IOException ex){
		throw new SchemaException("Schema error during serializing to JSON.", ex);
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:12,代码来源:YamlLexicalProcessor.java

示例6: yamlFactory

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
private static YAMLFactory yamlFactory() {
	return
		new YAMLFactory().
			disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER).
			disable(YAMLGenerator.Feature.CANONICAL_OUTPUT).
			enable(YAMLGenerator.Feature.SPLIT_LINES).
			enable(YAMLGenerator.Feature.MINIMIZE_QUOTES).
			enable(YAMLGenerator.Feature.USE_NATIVE_OBJECT_ID).
			enable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID);
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:11,代码来源:ConfigurationFactory.java

示例7: EmbulkOperatorFactory

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
@Inject
public EmbulkOperatorFactory(CommandExecutor exec, TemplateEngine templateEngine, CommandLogger clog, ObjectMapper mapper)
{
    this.exec = exec;
    this.clog = clog;
    this.templateEngine = templateEngine;
    this.mapper = mapper;
    this.yaml = new YAMLFactory()
        .configure(YAMLGenerator.Feature.WRITE_DOC_START_MARKER, false);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:11,代码来源:EmbulkOperatorFactory.java

示例8: YamlMapper

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
@Inject
public YamlMapper(ObjectMapper mapper)
{
    this.yaml = new YAMLFactory()
        .configure(YAMLGenerator.Feature.WRITE_DOC_START_MARKER, false);
    this.mapper = mapper;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:8,代码来源:YamlMapper.java

示例9: writeFile

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
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);
    }
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:11,代码来源:YamlMapper.java

示例10: toYaml

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
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);
    }
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:14,代码来源:YamlMapper.java

示例11: toYaml

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
/**
 * Convert this RAML object to Yaml.
 *
 * @return Yaml string.
 * @throws IOException If something goes wrong.
 */
public String toYaml() throws IOException {
  YAMLMapper mapper = new YAMLMapper();
  mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
  mapper.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, false);
  mapper.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true);
  return "#%RAML 1.0\n" + mapper.writer().withDefaultPrettyPrinter().writeValueAsString(this);
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:14,代码来源:Raml.java

示例12: write

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
public void write(YAMLGenerator generator, JsonNode merged) throws JsonProcessingException, IOException {
    mapper.writeTree(generator, merged);
}
 
开发者ID:otrosien,项目名称:yaml-merge,代码行数:4,代码来源:YamlMapper.java

示例13: createObjectMapper

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
/**
 * Creates a configured Jackson object mapper for parsing YAML
 */
public static ObjectMapper createObjectMapper() {
    YAMLFactory yamlFactory = new YAMLFactory();
    yamlFactory.configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false);
    return new ObjectMapper(yamlFactory);
}
 
开发者ID:funktionio,项目名称:funktion-connectors,代码行数:9,代码来源:Funktions.java

示例14: YAMLConfigurationProvider

import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; //导入依赖的package包/类
public YAMLConfigurationProvider(String fileName) {
    this.fileName = fileName;
    factory = new YAMLFactory();
    mapper = new ObjectMapper(factory);
    factory.configure(YAMLGenerator.Feature.WRITE_DOC_START_MARKER, false);
}
 
开发者ID:walkmod,项目名称:walkmod-core,代码行数:7,代码来源:YAMLConfigurationProvider.java


注:本文中的com.fasterxml.jackson.dataformat.yaml.YAMLGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。