本文整理了Java中com.sk89q.util.yaml.YAMLProcessor.setComment()
方法的一些代码示例,展示了YAMLProcessor.setComment()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLProcessor.setComment()
方法的具体详情如下:
包路径:com.sk89q.util.yaml.YAMLProcessor
类名称:YAMLProcessor
方法名:setComment
[英]Set a root-level comment.
[中]设置根级别的注释。
代码示例来源:origin: EngineHub/WorldEdit
public void setComment(String key, String comment) {
if (comment != null) {
setComment(key, comment.split("\\r?\\n"));
} else {
comments.remove(key);
}
}
代码示例来源:origin: EngineHub/CommandBook
/**
* Loads the configuration.
*/
@Override
public YAMLProcessor createConfiguration() {
final File configFile = new File(getDataFolder(), "config.yml");
YAMLProcessor config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED);
YAMLProcessor comments = new DefaultsFileYAMLProcessor("config-comments.yml", false);
try {
if (!configFile.exists()) {
configFile.getParentFile().mkdirs();
configFile.createNewFile();
}
config.load();
comments.load();
} catch (Exception e) {
getLogger().log(Level.WARNING, "Error loading configuration: ", e);
}
for (Map.Entry<String, Object> e : comments.getMap().entrySet()) {
if (e.getValue() != null) {
config.setComment(e.getKey(), e.getValue().toString());
}
}
// Migrate the old configuration, if we need to
final String result = new LegacyCommandBookConfigurationMigrator(configFile, config).migrate();
if (result != null) {
logger().severe("Error migrating CommandBook configuration: " + result);
}
return config;
}
内容来源于网络,如有侵权,请联系作者删除!