private Map<String, String> getReplacements(final Config config, final String keyName) { final Map<String, String> replacements = new HashMap<>(); for (String url : config.getSubsections(KEY_URL)) for (String insteadOf : config.getStringList(KEY_URL, url, keyName)) replacements.put(insteadOf, url); return replacements; }
/** {@inheritDoc} */ @Override @NonNull public List<RefSpec> getRefSpecs(Config config, String section, String subsection, String name) { String[] values = config.getStringList(section, subsection, name); List<RefSpec> result = new ArrayList<>(values.length); for (String spec : values) { result.add(new RefSpec(spec)); } return result; } }
String[] base; if (baseConfig != null) base = baseConfig.getStringList(section, subsection, name); else base = EMPTY_STRING_ARRAY;
String val; vlst = rc.getStringList(SECTION, name, KEY_URL); Map<String, String> insteadOf = getReplacements(rc, KEY_INSTEADOF); uris = new ArrayList<>(vlst.length); uris.add(new URIish(replaceUri(s, insteadOf))); String[] plst = rc.getStringList(SECTION, name, KEY_PUSHURL); pushURIs = new ArrayList<>(plst.length); for (String s : plst) {
"uploadpack", "allowfilter", false); protocolVersion = ProtocolVersion.parse(rc.getString("protocol", null, "version")); hideRefs = rc.getStringList("uploadpack", null, "hiderefs");
public String[] getStringList(String section, String subsection, String name) { if (KEY_URL.equals(name)) return uris; if (KEY_FETCH.equals(name)) return fetch; if (KEY_PUSH.equals(name)) return push; return super.getStringList(section, subsection, name); }
public String[] getStringList(String section, String subsection, String name) { List<String> result = stringsListMap.get(name); if (null != result) { return result.toArray(new String[result.size()]); } return super.getStringList(section, subsection, name); }
private Map<String, String> getReplacements(final Config config, final String keyName) { final Map<String, String> replacements = new HashMap<String, String>(); for (String url : config.getSubsections(KEY_URL)) for (String insteadOf : config.getStringList(KEY_URL, url, keyName)) replacements.put(insteadOf, url); return replacements; }
private Map<String, String> getReplacements(final Config config, final String keyName) { final Map<String, String> replacements = new HashMap<>(); for (String url : config.getSubsections(KEY_URL)) for (String insteadOf : config.getStringList(KEY_URL, url, keyName)) replacements.put(insteadOf, url); return replacements; }
private List<SocketAddress> parseListen(final Config cfg) { final ArrayList<SocketAddress> bind = new ArrayList<SocketAddress>(2); final String[] want = cfg.getStringList("sshd", null, "listenaddress"); if (want == null || want.length == 0) { bind.add(new InetSocketAddress(DEFAULT_PORT)); return bind; } for (final String desc : want) { try { bind.add(SocketUtil.resolve(desc, DEFAULT_PORT)); } catch (IllegalArgumentException e) { log.error("Bad sshd.listenaddress: " + desc + ": " + e.getMessage()); } } return bind; }
private List<SocketAddress> parseListen(final Config cfg) { final ArrayList<SocketAddress> bind = new ArrayList<SocketAddress>(2); final String[] want = cfg.getStringList("sshd", null, "listenaddress"); if (want == null || want.length == 0) { bind.add(new InetSocketAddress(DEFAULT_PORT)); return bind; } for (final String desc : want) { try { bind.add(SocketUtil.resolve(desc, DEFAULT_PORT)); } catch (IllegalArgumentException e) { log.error("Bad sshd.listenaddress: " + desc + ": " + e.getMessage()); } } return bind; }
/** {@inheritDoc} */ @Override @NonNull public List<RefSpec> getRefSpecs(Config config, String section, String subsection, String name) { String[] values = config.getStringList(section, subsection, name); List<RefSpec> result = new ArrayList<>(values.length); for (String spec : values) { result.add(new RefSpec(spec)); } return result; } }
public void addValue(String newValue) { if (newValue.length() == 0) throw new IllegalArgumentException( UIText.ConfigurationEditorComponent_EmptyStringNotAllowed); Config config = getConfig(); List<String> entries; if (sectionparent != null) { // Arrays.asList returns a fixed-size list, so we need to copy // over to a mutable list entries = new ArrayList<String>(Arrays.asList(config .getStringList(sectionparent.name, null, name))); entries.add(Math.max(index, 0), newValue); config.setStringList(sectionparent.name, null, name, entries); } else { // Arrays.asList returns a fixed-size list, so we need to copy // over to a mutable list entries = new ArrayList<String>(Arrays.asList(config .getStringList(subsectionparent.parent.name, subsectionparent.name, name))); entries.add(Math.max(index, 0), newValue); config.setStringList(subsectionparent.parent.name, subsectionparent.name, name, entries); } }
/** * Parse a Java enumeration list from the configuration. * * @param <T> type of the enumeration object. * @param config the configuration file to read. * @param section section the key is in. * @param subsection subsection the key is in, or null if not in a subsection. * @param setting name of the setting to read. * @param all all possible values in the enumeration which should be * recognized. This should be {@code EnumType.values()}. * @param defaultValue default value to return if the setting was not set. * This value may be null. * @return the selected enumeration values list, or {@code defaultValue}. */ public static <T extends Enum<?>> List<T> getEnumList(final Config config, final String section, final String subsection, final String setting, final T[] all, final T defaultValue) { final List<T> list = new ArrayList<T>(); final String[] values = config.getStringList(section, subsection, setting); if (values.length == 0) { list.add(defaultValue); } else { for (String string : values) { if (string != null) { list.add(getEnum(section, subsection, setting, string, all)); } } } return list; }
String[] base; if (baseConfig != null) base = baseConfig.getStringList(section, subsection, name); else base = EMPTY_STRING_ARRAY;
public Object[] getChildren(Object o) { if (children == null) { List<Entry> entries = new ArrayList<Entry>(); Set<String> entryNames = config.getNames(parent.name, name); for (String entryName : entryNames) { String[] values = config.getStringList(parent.name, name, entryName); if (values.length == 1) entries.add(new Entry(this, entryName, values[0], -1)); else { int index = 0; for (String value : values) entries.add(new Entry(this, entryName, value, index++)); } } children = entries.toArray(new Entry[entries.size()]); } return children; }
.getStringList(sectionparent.name, null, name))); .getStringList(subsectionparent.parent.name, subsectionparent.name, name)));
public void changeValue(String newValue) throws IllegalArgumentException { if (newValue.length() == 0) throw new IllegalArgumentException( UIText.ConfigurationEditorComponent_EmptyStringNotAllowed); Config config = getConfig(); if (index < 0) { if (sectionparent != null) config.setString(sectionparent.name, null, name, newValue); else config.setString(subsectionparent.parent.name, subsectionparent.name, name, newValue); } else { String[] entries; if (sectionparent != null) { entries = config.getStringList(sectionparent.name, null, name); entries[index] = newValue; config.setStringList(sectionparent.name, null, name, Arrays.asList(entries)); } else { entries = config.getStringList( subsectionparent.parent.name, subsectionparent.name, name); entries[index] = newValue; config.setStringList(subsectionparent.parent.name, subsectionparent.name, name, Arrays.asList(entries)); } } }
public Object[] getChildren(Object o) { if (children == null) { List<Object> allChildren = new ArrayList<Object>(); Set<String> subSectionNames = parent.config .getSubsections(name); for (String subSectionName : subSectionNames) allChildren.add(new SubSection(parent.config, this, subSectionName)); Set<String> entryNames = parent.config.getNames(name); for (String entryName : entryNames) { String[] values = parent.config.getStringList(name, null, entryName); if (values.length == 1) allChildren.add(new Entry(this, entryName, values[0], -1)); else { int index = 0; for (String value : values) allChildren.add(new Entry(this, entryName, value, index++)); } } children = allChildren.toArray(); } return children; }
private List<Project> parseProjects(final Config cfg, final String sectionName) { final List<Project> dst = new ArrayList<Project>(); for (String id : cfg.getSubsections(sectionName)) { String name = cfg.getString(sectionName, id, K_NAME); Project project = new Project(id, name); project.setVersion(cfg.getString(sectionName, id, K_VERSION)); project.setComments(cfg.getString(sectionName, id, K_COMMENTS)); for (String c : cfg.getStringList(sectionName, id, K_SKIP_COMMIT)) project.addSkipCommit(ObjectId.fromString(c)); for (String license : cfg.getStringList(sectionName, id, K_LICENSE)) project.addLicense(license); dst.add(project); } return dst; }