/** * Get the unmodifiable set of keys of the first section. * The set has insertion order. * * @return the keys of the first section */ public Collection<String> getKeys() { IniSection section = getSection(); return section == null ? null : section.getKeys(); }
/** * 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); } } } /**
List<String> knownKeys = new ArrayList(copy.getKeys()); writer.print("["); writer.print(copy.getName());
public static void report(final IniSection config) { StringBuilder buf = new StringBuilder(config.report()); for (String key : config.getKeys()) { ConfigEntryType type = ConfigEntryType.fromString(key);
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); } } }
@Override public Document toOSIS() { List<String> knownKeys = new ArrayList(configAll.getKeys()); OSISUtil.OSISFactory factory = OSISUtil.factory(); Element table = factory.createTable(); Element row = toRow(factory, "Initials", getInitials()); table.addContent(row); // Each key gets one row. for (String key : OSIS_INFO) { knownKeys.remove(key); row = toRow(factory, key); if (row != null) { table.addContent(row); } } // Output the rest in the order that they are in the conf // however, don't show those that should be hidden. List<String> hide = Arrays.asList(HIDDEN); for (String key : knownKeys) { if (hide.contains(key)) { continue; } row = toRow(factory, key); if (row != null) { table.addContent(row); } } return new Document(table); }
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); } } } }