本文整理汇总了Java中com.esotericsoftware.yamlbeans.YamlConfig类的典型用法代码示例。如果您正苦于以下问题:Java YamlConfig类的具体用法?Java YamlConfig怎么用?Java YamlConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
YamlConfig类属于com.esotericsoftware.yamlbeans包,在下文中一共展示了YamlConfig类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
@Override
public void save(T object) {
try {
YamlWriter writer = new YamlWriter(new FileWriter(getFile()));
writer.getConfig().writeConfig.setIndentSize(2);
writer.getConfig().writeConfig.setAutoAnchor(false);
writer.getConfig().writeConfig.setWriteDefaultValues(true);
writer.getConfig().writeConfig.setWriteRootTags(false);
writer.getConfig().writeConfig.setWriteClassname(YamlConfig.WriteClassName.NEVER);
writer.write(object);
writer.close();
} catch (IOException exception) {
exception.printStackTrace();
}
}
示例2: saveTokensToFile
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
protected void saveTokensToFile(TargetInfos targetInfos) {
final File tokensFile = getTokensFile();
tokensFile.getParentFile().mkdirs();
try {
FileWriter fileWriter = new FileWriter(tokensFile);
YamlConfig config = new YamlConfig();
config.writeConfig.setAlwaysWriteClassname(false);
config.writeConfig.setWriteRootElementTags(false);
config.writeConfig.setWriteRootTags(false);
config.writeConfig.setExplicitFirstDocument(true);
YamlWriter yamlWriter = new YamlWriter(fileWriter, config);
yamlWriter.write(targetInfos);
yamlWriter.close();
fileWriter.close();
} catch (IOException e) {
throw new RuntimeException("An error occurred writing the tokens file at " +
tokensFile.getPath() + ":" + e.getMessage(), e);
}
}
示例3: unmarshal
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see marshalsec.MarshallerBase#unmarshal(java.lang.Object)
*/
@Override
public Object unmarshal ( String data ) throws Exception {
YamlConfig yc = new YamlConfig();
YamlReader r = new YamlReader(data, yc);
return r.read();
}
示例4: adjustConfig
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
/**
* Adjusts the {@link YamlConfig} to our UseCase.
*
* @param config The initial {@link YamlConfig}
*/
private void adjustConfig(YamlConfig config) {
config.setPropertyElementType(ServiceTemplate.class, "inputs", Input.class);
config.setPropertyElementType(ServiceTemplate.class, "node_templates", NodeTemplate.class);
config.setPropertyElementType(ServiceTemplate.class, "node_types", NodeType.class);
config.setPropertyElementType(ServiceTemplate.class, "capability_types", CapabilityType.class);
config.setPropertyElementType(ServiceTemplate.class, "relationship_types", RelationshipType.class);
config.setPropertyElementType(ServiceTemplate.class, "artifact_types", ArtifactType.class);
config.setPropertyElementType(ServiceTemplate.class, "groups", Group.class);
config.setPropertyElementType(ServiceTemplate.class, "outputs", Output.class);
config.setPropertyElementType(NodeType.class, "properties", PropertyDefinition.class);
config.setPropertyElementType(RelationshipType.class, "properties", PropertyDefinition.class);
config.setPropertyElementType(CapabilityType.class, "properties", PropertyDefinition.class);
config.setPropertyElementType(CapabilityDefinition.class, "properties", PropertyDefinition.class);
config.setPropertyElementType(ArtifactType.class, "properties", PropertyDefinition.class);
}
示例5: marshal
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see marshalsec.MarshallerBase#marshal(java.lang.Object)
*/
@Override
public String marshal ( Object o ) throws Exception {
YamlConfig yc = new YamlConfig();
StringWriter sw = new StringWriter();
YamlWriter w = new YamlWriter(sw, yc);
w.write(o);
return sw.toString();
}
示例6: setRegisteredClasses
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
private void setRegisteredClasses(YamlConfig config) {
for (ConfigReg configReg : registerList) {
if (configReg.getType() == Register.DEFAULT) {
config.setPropertyDefaultType(configReg.getParent(), configReg.getName(), configReg.getChild());
} else {
config.setPropertyElementType(configReg.getParent(), configReg.getName(), configReg.getChild());
}
}
for (Map.Entry<String, Class<?>> entry : tagMap.entrySet()) {
config.setClassTag(entry.getKey(), entry.getValue());
}
}
示例7: createYamlReader
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
/**
* Creates an {@link YamlReader} to read an YAML file and instantiate
* java objects for the entries inside the file.
*
* @return the {@link YamlReader} to enable reading the YAML file
* @throws FileNotFoundException
*/
private YamlReader createYamlReader() throws FileNotFoundException {
final YamlReader reader = new YamlReader(new FileReader(file));
final YamlConfig cfg = reader.getConfig();
//Defines the aliases in the YAML file that refers to specific java Classes.
cfg.setClassTag("datacenter", DatacenterRegistry.class);
cfg.setClassTag("customer", CustomerRegistry.class);
cfg.setClassTag("san", SanStorageRegistry.class);
cfg.setClassTag("host", HostRegistry.class);
cfg.setClassTag("cloudlet", CloudletRegistry.class);
cfg.setClassTag("vm", VmRegistry.class);
return reader;
}
示例8: writeDocument
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
private String writeDocument(YamlDocument yaml) throws YamlException {
StringWriter writer = new StringWriter();
YamlConfig config = new YamlConfig();
config.writeConfig.setExplicitFirstDocument(yaml.getTag()!=null);
config.writeConfig.setWriteClassname(WriteClassName.NEVER);
config.writeConfig.setAutoAnchor(false);
YamlWriter yamlWriter = new YamlWriter(writer, config);
yamlWriter.write(yaml);
yamlWriter.close();
return writer.toString();
}
示例9: readYamlObject
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
public static Object readYamlObject(String path) throws IOException {
YamlConfig config = new YamlConfig();
config.setAllowDuplicates(false);
YamlReader reader = new YamlReader(TestUtils.createReader(path), config);
return reader.read();
}
示例10: configure
import com.esotericsoftware.yamlbeans.YamlConfig; //导入依赖的package包/类
public static void configure(YamlConfig config) {
config.setPropertyElementType(ExperimentConfiguration.class, "projects", Project.class);
config.setPropertyElementType(ExperimentConfiguration.class, "files", ExpFile.class);
}