- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.sk89q.util.yaml.YAMLProcessor
类的一些代码示例,展示了YAMLProcessor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLProcessor
类的具体详情如下:
包路径:com.sk89q.util.yaml.YAMLProcessor
类名称:YAMLProcessor
[英]YAML configuration loader. To use this class, construct it with path to a file and call its load() method. For specifying node paths in the various get*() methods, they support SK's path notation, allowing you to select child nodes by delimiting node names with periods.
For example, given the following configuration file:
members:
- Hollie
- Jason
- Bobo
- Aya
- Tetsu
worldguard:
fire:
spread: false
blocks: [cloth, rock, glass]
sturmeh:
cool: false
eats:
babies: true
Calling code could access sturmeh's baby eating state by using getBoolean("sturmeh.eats.babies", false). For lists, there are methods such as getStringList that will return a type safe list.
[中]YAML配置加载程序。要使用这个类,请使用文件的路径构造它,并调用其load()方法。为了在各种get*()方法中指定节点路径,它们支持SK的路径表示法,允许您通过用句点分隔节点名称来选择子节点。
例如,给定以下配置文件:
members:
- Hollie
- Jason
- Bobo
- Aya
- Tetsu
worldguard:
fire:
spread: false
blocks: [cloth, rock, glass]
sturmeh:
cool: false
eats:
babies: true
调用代码可以使用getBoolean(“sturmeh.eats.babyes”,false)访问sturmeh的婴儿进食状态。对于列表,有一些方法(如getStringList)将返回类型安全列表。
代码示例来源:origin: EngineHub/WorldEdit
config = new YAMLProcessor(file, false, YAMLFormat.EXTENDED);
try {
config.load();
} catch (IOException e) {
logger.log(Level.WARNING, "Error loading WEPIF configuration", e);
List<String> keys = config.getKeys(null);
config.setHeader(CONFIG_HEADER);
config.setProperty("ignore-nijiperms-bridges", true);
isUpdated = true;
config.setProperty("resolvers.enabled", resolvers);
isUpdated = true;
} else {
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<>());
List<String> stagedEnabled = config.getStringList("resolvers.enabled", null);
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext();) {
String nextName = i.next();
config.setProperty("resolvers.disabled", disabledResolvers);
config.setProperty("resolvers.enabled", stagedEnabled);
config.removeProperty("dinner-perms");
config.removeProperty("dinnerperms");
isUpdated = true;
config.addNode("permissions"));
isUpdated = true;
代码示例来源:origin: EngineHub/WorldEdit
@Override
public void load() {
try {
config.load();
} catch (IOException e) {
logger.log(Level.WARNING, "Error loading WorldEdit configuration", e);
profile = config.getBoolean("debug", profile);
traceUnflushedSessions = config.getBoolean("debugging.trace-unflushed-sessions", traceUnflushedSessions);
wandItem = convertLegacyItem(config.getString("wand-item", wandItem));
defaultChangeLimit = Math.max(-1, config.getInt(
"limits.max-blocks-changed.default", defaultChangeLimit));
maxChangeLimit = Math.max(-1,
config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit));
config.getInt("limits.max-polygonal-points.default", defaultMaxPolygonalPoints));
maxPolygonalPoints = Math.max(-1,
config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints));
defaultMaxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.default", defaultMaxPolyhedronPoints));
maxPolyhedronPoints = Math.max(-1, config.getInt("limits.max-polyhedron-points.maximum", maxPolyhedronPoints));
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
maxSuperPickaxeSize = Math.max(1, config.getInt(
"limits.max-super-pickaxe-size", maxSuperPickaxeSize));
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
代码示例来源:origin: EngineHub/WorldGuard
config = new YAMLProcessor(new File(getDataFolder(), "config.yml"), true, YAMLFormat.EXTENDED);
try {
config.load();
} catch (IOException e) {
log.severe("Error reading configuration for global config: ");
config.removeProperty("suppress-tick-sync-warnings");
migrateRegionsToUuid = config.getBoolean("regions.uuid-migration.perform-on-next-start", true);
keepUnresolvedNames = config.getBoolean("regions.uuid-migration.keep-names-that-lack-uuids", true);
useRegionsCreatureSpawnEvent = config.getBoolean("regions.use-creature-spawn-event", true);
useGodPermission = config.getBoolean("auto-invincible", config.getBoolean("auto-invincible-permission", false));
useGodGroup = config.getBoolean("auto-invincible-group", false);
useAmphibiousGroup = config.getBoolean("auto-no-drowning-group", false);
config.removeProperty("auto-invincible-permission");
usePlayerMove = config.getBoolean("use-player-move-event", true);
usePlayerTeleports = config.getBoolean("use-player-teleports", true);
particleEffects = config.getBoolean("use-particle-effects", true);
deopOnJoin = config.getBoolean("security.deop-everyone-on-join", false);
blockInGameOp = config.getBoolean("security.block-in-game-op-command", false);
Object hostKeysRaw = config.getProperty("host-keys");
if (!(hostKeysRaw instanceof Map)) {
config.setProperty("host-keys", new HashMap<String, String>());
} else {
for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) hostKeysRaw).entrySet()) {
hostKeysAllowFMLClients = config.getBoolean("security.host-keys-allow-forge-clients", false);
代码示例来源:origin: EngineHub/CommandBook
private boolean reloadMessages() {
try {
help.load();
} catch (IOException e) {
return false;
}
List<String> keys = help.getKeys("topics");
if (keys == null) {
help.setProperty("topics.help", demoHelpMessage);
keys = new ArrayList<String>();
keys.add("help");
help.save();
}
for (String key : keys) {
String information = help.getString("topics." + key);
if (information != null && information.trim().length() != 0) {
information = replaceColorMacros(information);
String[] split = information.split("\\n");
for (int i = 0; i < split.length; i++) {
split[i] = split[i].replaceAll("[\\r\\n]", "");
}
messages.put(key.toLowerCase(), split);
}
}
return true;
}
代码示例来源:origin: EngineHub/CommandBook
@Override
public ConfigurationFile createConfigurationNode(File file) {
return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
jarComponentAliases.load();
} catch (IOException e) {
getLogger().severe("Error loading component aliases!");
new YAMLNodeConfigurationNode(jarComponentAliases), configDir));
for (String dir : config.getStringList("component-class-dirs", Arrays.asList("component-classes"))) {
final File classesDir = new File(getDataFolder(), dir);
if (!classesDir.exists() || !classesDir.isDirectory()) {
@Override
public ConfigurationFile createConfigurationNode(File file) {
return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
for (String dir : config.getStringList("component-jar-dirs", Arrays.asList("component-jars"))) {
final File classesDir = new File(getDataFolder(), dir);
if (!classesDir.exists() || !classesDir.isDirectory()) {
@Override
public ConfigurationFile createConfigurationNode(File file) {
return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
代码示例来源:origin: EngineHub/WorldGuard
public void loadConfiguration() {
try {
config.load();
} catch (IOException e) {
log.severe("Error reading configuration for world " + worldName + ": ");
config.setHeader(CONFIG_HEADER);
config.save();
代码示例来源:origin: EngineHub/CommandBook
public WrappedSpawn setWorldSpawn(Location loc) {
WrappedSpawn spawn = getEnrichment(loc.getWorld());
loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
spawn.setPitch(loc.getPitch());
spawn.setYaw(loc.getYaw());
config.setProperty(spawn.getWorldName() + ".pitch", spawn.getPitch());
config.setProperty(spawn.getWorldName() + ".yaw", spawn.getYaw());
config.setHeader(CONFIG_HEADER);
config.save();
return spawn;
}
代码示例来源:origin: EngineHub/WorldGuard
YAMLProcessor config = createYamlProcessor(tempFile);
config.clear();
YAMLNode regionsNode = config.addNode("regions");
Map<String, Object> map = regionsNode.getMap();
config.setHeader(FILE_HEADER);
config.save();
代码示例来源: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;
}
代码示例来源:origin: EngineHub/WorldEdit
private void loadConfig() {
createDefaultConfiguration("config.yml"); // Create the default configuration file
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
config.load();
}
代码示例来源:origin: EngineHub/WorldGuard
public List<String> getStringList(String node, List<String> def) {
List<String> res = parentConfig.getStringList(node, def);
if (res == null || res.size() == 0) {
parentConfig.setProperty(node, new ArrayList<String>());
}
if (config.getProperty(node) != null) {
res = config.getStringList(node, def);
}
return res;
}
代码示例来源:origin: EngineHub/WorldGuard
private TargetMatcherSet getTargetMatchers(String node) {
TargetMatcherSet set = new TargetMatcherSet();
List<String> inputs = parentConfig.getStringList(node, null);
if (inputs == null || inputs.size() == 0) {
parentConfig.setProperty(node, new ArrayList<String>());
return set;
}
for (String input : inputs) {
try {
set.add(matcherParser.fromInput(input));
} catch (TargetMatcherParseException e) {
log.warning("Failed to parse the block / item type specified as '" + input + "'");
}
}
return set;
}
代码示例来源:origin: EngineHub/CommandBook
processor = new YAMLProcessor(userFile, false, YAMLFormat.COMPACT);
try {
processor.load();
} catch (IOException e) {
CommandBook.logger().log(Level.WARNING, "Error loading sessions persistence file for user " + commander, e);
代码示例来源:origin: EngineHub/WorldGuard
@Override
public void disableUuidMigration() {
config.setProperty("regions.uuid-migration.perform-on-next-start", false);
if (!config.save()) {
log.severe("Error saving configuration!");
}
}
}
代码示例来源:origin: EngineHub/CommandBook
public void load() {
storedSpawns.clear();
try {
config.load();
} catch (IOException ignore) {}
for (World world : Bukkit.getServer().getWorlds())
loadWorld(world);
}
代码示例来源:origin: EngineHub/WorldEdit
/**
* Set the header for the file as a series of lines that are terminated
* by a new line sequence.
*
* @param headerLines header lines to prepend
*/
public void setHeader(String... headerLines) {
StringBuilder header = new StringBuilder();
for (String line : headerLines) {
if (header.length() > 0) {
header.append(LINE_BREAK);
}
header.append(line);
}
setHeader(header.toString());
}
代码示例来源:origin: EngineHub/WorldGuard
public List<Integer> getIntList(String node, List<Integer> def) {
List<Integer> res = parentConfig.getIntList(node, def);
if (res == null || res.size() == 0) {
parentConfig.setProperty(node, new ArrayList<Integer>());
}
if (config.getProperty(node) != null) {
res = config.getIntList(node, def);
}
return res;
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public void load() {
super.load();
noOpPermissions = config.getBoolean("no-op-permissions", false);
migrateLegacyFolders();
}
代码示例来源:origin: EngineHub/CommandBook
@Command(aliases = {"save"}, usage = "", desc = "Save CommandBook's settings", min = 0, max = 0)
@CommandPermissions({"commandbook.save"})
public static void save(CommandContext args, CommandSender sender) throws CommandException {
CommandBook.inst().getGlobalConfiguration().save();
sender.sendMessage(ChatColor.YELLOW + "CommandBook's configuration has been reloaded.");
}
代码示例来源:origin: EngineHub/WorldEdit
List<String> groupKeys = config.getStringList("permissions.groups", null);
config.getStringList("permissions.groups." + key + ".permissions", null);
List<String> userKeys = config.getStringList("permissions.users", null);
config.getStringList("permissions.users." + key + ".permissions", null);
config.getStringList("permissions.users." + key + ".groups", null);
groups.add("default");
是否可以在 yaml 中存储未转义的 Markdown 文档?我测试过 key:|+ markdown text block that could have any combination o
在解析使用两个空格缩进创建的 YAML(使用 Ruby 2.5/Psych)时,我看到了奇怪的行为。同一个文件,每行缩进四个空格 - 在我看来 - 正如预期的那样。 两个空格: windows:
如何在 yaml 文件中使用三元运算符让 snakeparser 解析它 我使用 groovy 来解析表达式,!e 标签帮助我这样做。现在,当我使用三元运算符时,解析器会失败。 name : abc
是否可以有这样的多行键? mykey: - > key one: keytwo: val 其中 keyone 被视为一个键。我想解析 yaml 以产生: { mykey:
我有一个 YAML 文件,它有几个不同的键,我想为其提供相同的值。此外,我希望该值易于配置。 请参阅下面的 YAML 以了解我的特定用例: --- # Options for attribute_va
在 Perl 中,我可以执行以下操作: my $home = "/home"; my $alice = "$home/alice"; 我可以在 YAML 中执行以下操作: Home: /home Al
如何在 YAML 中表示空字典? IE。它在语义上应该等同于空的 json-object {}。 最佳答案 简短回答:使用 {} 在 yaml 中有两种表示映射(字典)的方法; flow mappin
我需要根据 if 条件再添加一个名称。如果另一个 .yml 文件中的变量值为“yes”,则在列表中添加新名称 我的 yaml 文件中有以下代码: JsNames: - name: 'jquery.m
我是 yaml 新手,我对用于多行的管道符号 (|) 有疑问。 YAML 是否有类似下面的语法? test: |6+ 在下面的两个 YAML 文件中,第一个有效,第二个无效。我不知道是什么原因造成的。
关于 YAML specs关于问号有2.11段: A question mark and space (“? ”) indicate a complex mapping key. Within a b
1。摘要 我找不到如何自动美化我的 YAML 文件。 2。数据 示例: 我有 SashaPrettifyYAML.yaml 文件: sasha_commands: # Sasha comm
我试图理解 YAML 的基本概念。我没有找到任何相关文档可以消除我的疑虑。例如: product: - sku : BL394D quantity : 4
1。摘要 我找不到如何自动美化我的 YAML 文件。 2。数据 示例: 我有 SashaPrettifyYAML.yaml 文件: sasha_commands: # Sasha comm
是否有在 YAML 键中使用空格的正确方法?喜欢 a test: "hello world!" 或 "a test": "hello world!" 或者这只是一个坏主意,应该使用 a_test: "
我在 YAML 中遇到这个问题通过 perl 使用时。谁能告诉我哪里出了问题。 我有一个代码片段 use YAML; ... my $ifdef_struct = YAML::Load(': unde
我有一系列 OpenCv 生成的 YAML 文件,想用 yaml-cpp 解析它们 我在简单的事情上做得很好,但矩阵表示很困难。 # Center of table tableCenter: !!op
有没有办法在启动文件期间加载的 ROS yaml 文件中使用环境变量? 例如, 测试启动: 例子.yaml: vehicle_name: "${VEHICLE_NAME}_robot
Pandoc 支持 YAML metadata block在 Markdown 文档中。这可以设置标题和作者等。它还可以通过更改字体大小、边距宽度和赋予包含的图形的框架大小来操纵 PDF 输出的外观。
我使用当前(2013/12/12)最新版本的 yaml-cpp。 我注意到 YAML::Load("")和 YAML::Load("---\n...") 导致 Null 节点,即 YAML::Load
我喜欢 YAML。 等等,让我备份。我喜欢看起来像这样的 YAML,甚至比 JSON 还要多: Projects: C/C++ Libraries: - libyaml # "C"
我是一名优秀的程序员,十分优秀!