protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) { for (Map.Entry<?, ?> entry : input.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); if (value instanceof Map) { convertMapsToSections((Map<?, ?>) value, section.createSection(key)); } else { section.set(key, value); } } }
@Override public void loadFromString(String contents) throws InvalidConfigurationException { Validate.notNull(contents, "Contents cannot be null"); Map<?, ?> input; try { input = (Map<?, ?>) yaml.load(contents); } catch (YAMLException e) { throw new InvalidConfigurationException(e); } catch (ClassCastException e) { throw new InvalidConfigurationException("Top level is not a Map."); } String header = parseHeader(contents); if (header.length() > 0) { options().header(header); } if (input != null) { convertMapsToSections(input, this); } }
protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) { for (Map.Entry<?, ?> entry : input.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); if (value instanceof Map) { convertMapsToSections((Map<?, ?>) value, section.createSection(key)); } else { section.set(key, value); } } }
@Override public void loadFromString(String contents) throws InvalidConfigurationException { Validate.notNull(contents, "Contents cannot be null"); Map<?, ?> input; try { input = (Map<?, ?>) yaml.load(contents); } catch (YAMLException e) { throw new InvalidConfigurationException(e); } catch (ClassCastException e) { throw new InvalidConfigurationException("Top level is not a Map."); } String header = parseHeader(contents); if (header.length() > 0) { options().header(header); } if (input != null) { convertMapsToSections(input, this); } }