本文整理汇总了Java中org.yaml.snakeyaml.Loader类的典型用法代码示例。如果您正苦于以下问题:Java Loader类的具体用法?Java Loader怎么用?Java Loader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Loader类属于org.yaml.snakeyaml包,在下文中一共展示了Loader类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadListing
import org.yaml.snakeyaml.Loader; //导入依赖的package包/类
public ApiListing loadListing( String section ) {
Yaml yaml = new Yaml( new Loader());
//TODO: fix line above
String yamlString = readClasspathFileAsString( "/apidoc/" + section + ".yaml" );
ApiListing listing = ( ApiListing ) yaml.load( yamlString );
return listing;
}
示例2: processConfiguration
import org.yaml.snakeyaml.Loader; //导入依赖的package包/类
@Override
protected void processConfiguration(final String configuration) {
final Constructor rootConstructor = new Constructor(YamlConfiguration.class);
TypeDescription typeDescription = new TypeDescription(YamlConfiguration.class);
typeDescription.putListPropertyType("rules", YamlRule.class);
typeDescription.putMapPropertyType("properties", String.class, String.class);
typeDescription.putListPropertyType("sources", SourceDirectory.class);
typeDescription.putListPropertyType("listeners", String.class);
rootConstructor.addTypeDescription(typeDescription);
YamlConfiguration loadedConfguration = (YamlConfiguration) new Yaml(new Loader(rootConstructor)).load(configuration);
setDoCyclicDependencyTest(loadedConfguration.isDoCyclicDependencyTest());
setThrowExceptionWhenNoPackages(loadedConfguration.isThrowExceptionWhenNoPackages());
for (YamlRule rule : loadedConfguration.getRules()) {
final Rule ruleToAdd = new Rule(rule.getId());
for (String packageToAdd : rule.getPackages()) {
ruleToAdd.addPackage(packageToAdd);
}
for (String violation : rule.getViolations()) {
ruleToAdd.addViolation(violation);
}
getRules().add(ruleToAdd);
}
final Properties loadedProperties = new Properties();
loadedProperties.putAll(loadedConfguration.getProperties());
addProperties(loadedProperties);
getSources().addAll(loadedConfguration.getSources());
getIncludedListeners().addAll(loadedConfguration.getListeners());
// TODO should we support exclusion of listeners?!
}