/** * Add a value for the key. Duplicate values are not allowed. * * @param key the key for the section * @param value the value for the key * @return whether the value was added or is already present. */ public boolean addValue(String key, String value) { IniSection section = getSection(); return section == null || section.add(key, value); }
/** * Add a key/value pair to a section. * If the section does not exist, it is created. * A null for key or value is not allowed. * An empty string for a key is not allowed. * * @param sectionName the name of the section * @param key the key for the section * @param value the value for the key * @return {@code true} if the element was added or already was present */ public boolean add(String sectionName, String key, String value) { IniSection section = getOrCreateSection(sectionName); return section.add(key, value); }
/** * Copy constructor * * @param config the config to copy */ public IniSection(IniSection config) { this.name = config.getName(); section = new HashMap<String, List<String>>(); for (String key : config.getKeys()) { for (String value : config.getValues(key)) { add(key, value); } } } /**
private static void adjustHistory(IniSection config) { // Iterate over a copy of the keys so that we don't get // a concurrent modification exception when we remove matching keys // and when we add new keys List<String> keys = new ArrayList(config.getKeys()); for (String key : keys) { String value = config.get(key); ConfigEntryType type = ConfigEntryType.fromString(key); if (ConfigEntryType.HISTORY.equals(type)) { config.remove(key); int pos = key.indexOf('_'); value = key.substring(pos + 1) + ' ' + value; config.add(KEY_HISTORY, value); } } }
String value = more(bin, line.substring(splitPos + 1).trim()); if (filter == null || filter.test(key)) { add(key, value);
private void mergeConfig(IniSection config) { for (String key : config.getKeys()) { ConfigEntryType type = ConfigEntryType.fromString(key); for (String value : config.getValues(key)) { if (type != null && type.mayRepeat()) { if (!configAll.containsValue(key, value)) { configAll.add(key, value); } } else { setProperty(key, value); } } } }