Java 类org.yaml.snakeyaml.Loader 实例源码
项目:usergrid
文件:ApiDoc.java
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;
}
项目:architecturerules
文件:YamlConfigurationFactory.java
@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?!
}