From bd8ec510a1c1d8ae474bceee7837311f9de05bdb Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 27 Jun 2013 09:26:35 -0400 Subject: [PATCH] Improve RPC documentation --- src/main/java/com/gitblit/IStoredSettings.java | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/gitblit/IStoredSettings.java b/src/main/java/com/gitblit/IStoredSettings.java index 790f8b6..acb9fc6 100644 --- a/src/main/java/com/gitblit/IStoredSettings.java +++ b/src/main/java/com/gitblit/IStoredSettings.java @@ -161,7 +161,7 @@ /** * Returns an long filesize from a string value such as 50m or 50mb - * @param name + * @param n * @param defaultValue * @return a long filesize or defaultValue if the key does not exist or can * not be parsed @@ -261,6 +261,41 @@ } /** + * Returns a list of space-separated integers from the specified key. + * + * @param name + * @return list of strings + */ + public List<Integer> getIntegers(String name) { + return getIntegers(name, " "); + } + + /** + * Returns a list of integers from the specified key using the specified + * string separator. + * + * @param name + * @param separator + * @return list of integers + */ + public List<Integer> getIntegers(String name, String separator) { + List<Integer> ints = new ArrayList<Integer>(); + Properties props = getSettings(); + if (props.containsKey(name)) { + String value = props.getProperty(name); + List<String> strings = StringUtils.getStringsFromValue(value, separator); + for (String str : strings) { + try { + int i = Integer.parseInt(str); + ints.add(i); + } catch (NumberFormatException e) { + } + } + } + return ints; + } + + /** * Returns a map of strings from the specified key. * * @param name @@ -288,6 +323,16 @@ } /** + * Override the specified key with the specified value. + * + * @param key + * @param value + */ + public void overrideSetting(String key, int value) { + overrides.put(key, "" + value); + } + + /** * Updates the values for the specified keys and persists the entire * configuration file. * -- Gitblit v1.9.1