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


Java YamlConfig类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:b0atnet,项目名称:torsion,代码行数:17,代码来源:YMLFileParser.java

示例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);
    }
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:23,代码来源:TokensFile.java

示例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();
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:12,代码来源:YAMLBeans.java

示例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);
}
 
开发者ID:CloudCycle2,项目名称:YAML_Transformer,代码行数:21,代码来源:YamlBeansConverter.java

示例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();
}
 
开发者ID:mbechler,项目名称:marshalsec,代码行数:14,代码来源:YAMLBeans.java

示例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());
    }
}
 
开发者ID:DemonWav,项目名称:EctoTokens,代码行数:13,代码来源:EctoTokens.java

示例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;
}
 
开发者ID:manoelcampos,项目名称:cloudsim-plus-automation,代码行数:22,代码来源:YamlCloudScenarioReader.java

示例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();
}
 
开发者ID:EsotericSoftware,项目名称:yamlbeans,代码行数:12,代码来源:YamlDocumentTest.java

示例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();
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:7,代码来源:TestUtils.java

示例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);
			
}
 
开发者ID:anatlyzer,项目名称:anatlyzer,代码行数:6,代码来源:ExperimentConfigurationSerializer.java


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