예제 #1
0
 protected static void set(
     Config rc, String section, String subsection, String name, String value) {
   if (value != null) {
     rc.setString(section, subsection, name, value);
   } else {
     rc.unset(section, subsection, name);
   }
 }
예제 #2
0
  /**
   * Add or modify a configuration value. The parameters will result in a configuration entry like
   * this.
   *
   * <pre>
   * [section &quot;subsection&quot;]
   *         name = value
   * </pre>
   *
   * @param section section name, e.g "branch"
   * @param subsection optional subsection value, e.g. a branch name
   * @param name parameter name, e.g. "filemode"
   * @param value parameter value
   */
  public void setLong(
      final String section, final String subsection, final String name, final long value) {
    final String s;

    if (value >= GiB && (value % GiB) == 0) s = String.valueOf(value / GiB) + " g";
    else if (value >= MiB && (value % MiB) == 0) s = String.valueOf(value / MiB) + " m";
    else if (value >= KiB && (value % KiB) == 0) s = String.valueOf(value / KiB) + " k";
    else s = String.valueOf(value);

    setString(section, subsection, name, s);
  }
예제 #3
0
 /**
  * Add or modify a configuration value. The parameters will result in a configuration entry like
  * this.
  *
  * <pre>
  * [section &quot;subsection&quot;]
  *         name = value
  * </pre>
  *
  * @param <T> type of the enumeration object.
  * @param section section name, e.g "branch"
  * @param subsection optional subsection value, e.g. a branch name
  * @param name parameter name, e.g. "filemode"
  * @param value parameter value
  */
 public <T extends Enum<?>> void setEnum(
     final String section, final String subsection, final String name, final T value) {
   String n = value.name().toLowerCase().replace('_', ' ');
   setString(section, subsection, name, n);
 }
예제 #4
0
 /**
  * Add or modify a configuration value. The parameters will result in a configuration entry like
  * this.
  *
  * <pre>
  * [section &quot;subsection&quot;]
  *         name = value
  * </pre>
  *
  * @param section section name, e.g "branch"
  * @param subsection optional subsection value, e.g. a branch name
  * @param name parameter name, e.g. "filemode"
  * @param value parameter value
  */
 public void setBoolean(
     final String section, final String subsection, final String name, final boolean value) {
   setString(section, subsection, name, value ? "true" : "false");
 }