本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createParser()
方法的一些代码示例,展示了YAMLFactory.createParser()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLFactory.createParser()
方法的具体详情如下:
包路径:com.fasterxml.jackson.dataformat.yaml.YAMLFactory
类名称:YAMLFactory
方法名:createParser
暂无
代码示例来源:origin: redisson/redisson
@Override
public YAMLParser createParser(String content) throws IOException {
return createParser(new StringReader(content));
}
代码示例来源:origin: redisson/redisson
@Override // since 2.4
public YAMLParser createParser(char[] data) throws IOException {
return createParser(new CharArrayReader(data, 0, data.length));
}
代码示例来源:origin: redisson/redisson
@Override // since 2.4
public YAMLParser createParser(char[] data, int offset, int len) throws IOException {
return createParser(new CharArrayReader(data, offset, len));
}
代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml
@Override // since 2.4
public YAMLParser createParser(char[] data, int offset, int len) throws IOException {
return createParser(new CharArrayReader(data, offset, len));
}
代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml
@Override // since 2.4
public YAMLParser createParser(char[] data) throws IOException {
return createParser(new CharArrayReader(data, 0, data.length));
}
代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml
@Override
public YAMLParser createParser(String content) throws IOException {
return createParser(new StringReader(content));
}
代码示例来源:origin: bootique/bootique
@Override
public Optional<JsonNode> apply(InputStream t) {
try {
YAMLParser parser = yamlFactory.createParser(t);
return Optional.ofNullable(mapper.readTree(parser));
} catch (IOException e) {
throw new RuntimeException("Error reading config data", e);
}
}
}
代码示例来源:origin: spullara/mustache.java
private JsonNode getSpec(String spec) throws IOException {
return new YAMLFactory(new YAMLMapper()).createParser(new InputStreamReader(
SpecTest.class.getResourceAsStream(
"/spec/specs/" + spec))).readValueAsTree();
}
代码示例来源:origin: NLPchina/elasticsearch-sql
YAMLParser yamlParser = null;
try {
yamlParser = yamlFactory.createParser(heighlightParam.toCharArray());
YamlXContentParser yamlXContentParser = new YamlXContentParser(NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, yamlParser);
Map<String, Object> map = yamlXContentParser.map();
代码示例来源: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: HubSpot/Singularity
@Test
public void testMergedConfigs() throws Exception {
final InputStream mergedConfigStream = buildConfigurationSourceProvider(DEFAULT_PATH).open(OVERRIDE_PATH);
final SingularityConfiguration mergedConfig = objectMapper.readValue(YAML_FACTORY.createParser(mergedConfigStream), SingularityConfiguration.class);
assertEquals(10000, mergedConfig.getCacheTasksMaxSize());
assertEquals(500, mergedConfig.getCacheTasksInitialSize());
assertEquals(100, mergedConfig.getCheckDeploysEverySeconds());
assertEquals("baseuser", mergedConfig.getDatabaseConfiguration().get().getUser());
assertEquals("overridepassword", mergedConfig.getDatabaseConfiguration().get().getPassword());
}
代码示例来源:origin: io.digdag/digdag-cli
public <T> T readFile(File file, Class<T> type)
throws IOException
{
// TODO use yaml if file path ends with dig or yml, otherwise use json?
try (YAMLParser out = yaml.createParser(new FileInputStream(file))) {
// TODO write to a String first, then write to file. to not create partially-written broken file
return mapper.readValue(out, type);
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch-x-content
@Override
public XContentParser createParser(NamedXContentRegistry xContentRegistry,
DeprecationHandler deprecationHandler, byte[] data) throws IOException {
return new YamlXContentParser(xContentRegistry, deprecationHandler, yamlFactory.createParser(data));
}
代码示例来源:origin: org.elasticsearch/elasticsearch-x-content
@Override
public XContentParser createParser(NamedXContentRegistry xContentRegistry,
DeprecationHandler deprecationHandler, Reader reader) throws IOException {
return new YamlXContentParser(xContentRegistry, deprecationHandler, yamlFactory.createParser(reader));
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch-x-content
@Override
public XContentParser createParser(NamedXContentRegistry xContentRegistry,
DeprecationHandler deprecationHandler, String content) throws IOException {
return new YamlXContentParser(xContentRegistry, deprecationHandler, yamlFactory.createParser(new StringReader(content)));
}
代码示例来源:origin: org.elasticsearch/elasticsearch-x-content
@Override
public XContentParser createParser(NamedXContentRegistry xContentRegistry,
DeprecationHandler deprecationHandler, InputStream is) throws IOException {
return new YamlXContentParser(xContentRegistry, deprecationHandler, yamlFactory.createParser(is));
}
代码示例来源:origin: org.codelibs/elasticsearch-querybuilders
@Override
public XContentParser createParser(NamedXContentRegistry xContentRegistry, Reader reader) throws IOException {
return new YamlXContentParser(xContentRegistry, yamlFactory.createParser(reader));
}
}
代码示例来源: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: dayatang/dddlib
@Override
public Set<ClassDefinition> parseReader(Reader in) {
final JsonNode node;
try {
node = objectMapper.readTree(yamlFactory.createParser(in));
PackageDefinition packageDefinition = objectMapper.readValue(new TreeTraversingParser(node), PackageDefinition.class);
return toClassDefinitions(packageDefinition);
} catch (IOException e) {
throw new ParsingException("Cannot parse reader!");
}
}
代码示例来源:origin: com.hubspot/SingularityService
@Test
public void testMergedConfigs() throws Exception {
final InputStream mergedConfigStream = buildConfigurationSourceProvider(DEFAULT_PATH).open(OVERRIDE_PATH);
final SingularityConfiguration mergedConfig = objectMapper.readValue(YAML_FACTORY.createParser(mergedConfigStream), SingularityConfiguration.class);
assertEquals(10000, mergedConfig.getCacheTasksMaxSize());
assertEquals(500, mergedConfig.getCacheTasksInitialSize());
assertEquals(100, mergedConfig.getCheckDeploysEverySeconds());
assertEquals("baseuser", mergedConfig.getDatabaseConfiguration().get().getUser());
assertEquals("overridepassword", mergedConfig.getDatabaseConfiguration().get().getPassword());
}
内容来源于网络,如有侵权,请联系作者删除!