/** * Get a list of string values * * <p>If this instance was created with a base, the base's values are returned first (if any). * * @param section the section * @param subsection the subsection for the value * @param name the key name * @return array of zero or more values from the configuration. */ public String[] getStringList(final String section, String subsection, final String name) { final String[] baseList; if (baseConfig != null) baseList = baseConfig.getStringList(section, subsection, name); else baseList = EMPTY_STRING_ARRAY; final List<String> lst = getRawStringList(section, subsection, name); if (lst != null) { final String[] res = new String[baseList.length + lst.size()]; int idx = baseList.length; System.arraycopy(baseList, 0, res, 0, idx); for (final String val : lst) res[idx++] = val; return res; } return baseList; }
private Object getValueFromConfig(Config config, String keyString) { StringTokenizer tok = new StringTokenizer(keyString, "."); // $NON-NLS-1$ String section; String subsection; String name; String[] valueList = null; if (tok.countTokens() == 2) { section = tok.nextToken(); subsection = null; name = tok.nextToken(); } else if (tok.countTokens() == 3) { section = tok.nextToken(); subsection = tok.nextToken(); name = tok.nextToken(); } else { return ""; //$NON-NLS-1$ } if (getSingleValueMode()) valueList = new String[] {config.getString(section, subsection, name)}; else valueList = config.getStringList(section, subsection, name); if (valueList == null || valueList.length == 0) return null; if (valueList.length == 1) { return valueList[0]; } StringBuilder sb = new StringBuilder(); for (String value : valueList) { sb.append('['); sb.append(value); sb.append(']'); } return sb.toString(); }
public GitBlitUrlsConfig(Config config) { canonicalWebUrlString = config.getString("gerrit", null, "canonicalWebUrl"); sshdListenAddressString = config.getString("sshd", null, "listenAddress"); httpdListenUrlString = config.getString("httpd", null, "listenUrl"); downloadSchemes = Arrays.asList(config.getStringList("download", null, "scheme")); }
private static boolean isEmptyString(Config cfg, String section, String subsection, String name) { // This is currently the only way to check for the empty string in a JGit // config. Fun! String[] values = cfg.getStringList(section, subsection, name); return values.length > 0 && Strings.isNullOrEmpty(values[0]); }