directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject directory-kerby git commit: DIRKRB-175 Extend Config API to allow set values in additon to get values
Date Tue, 17 Mar 2015 21:43:26 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 7ac212fcb -> 9ca5d36e4


DIRKRB-175 Extend Config API to allow set values in additon to get values


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/9ca5d36e
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/9ca5d36e
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/9ca5d36e

Branch: refs/heads/master
Commit: 9ca5d36e4072ff1d1721bedc0683df7637739739
Parents: 7ac212f
Author: Drankye <drankye@gmail.com>
Authored: Wed Mar 18 05:43:06 2015 +0800
Committer: Drankye <drankye@gmail.com>
Committed: Wed Mar 18 05:43:06 2015 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kerby/config/Conf.java | 50 ++++++++++++
 .../java/org/apache/kerby/config/Config.java    | 81 ++++++++++++++++++++
 .../org/apache/kerby/config/ConfigImpl.java     | 55 ++++++++++++-
 3 files changed, 182 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9ca5d36e/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
index b426c02..2eeb05c 100644
--- a/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/Conf.java
@@ -135,6 +135,16 @@ public class Conf implements Config {
     }
 
     @Override
+    public void setString(String name, String value) {
+        config.setString(name, value);
+    }
+
+    @Override
+    public void setString(ConfigKey name, String value) {
+        config.setString(name, value);
+    }
+
+    @Override
     public String getTrimmed(String name) {
         checkAndLoad();
         return config.getTrimmed(name);
@@ -165,6 +175,16 @@ public class Conf implements Config {
     }
 
     @Override
+    public void setBoolean(String name, boolean value) {
+        config.setBoolean(name, value);
+    }
+
+    @Override
+    public void setBoolean(ConfigKey name, boolean value) {
+        config.setBoolean(name, value);
+    }
+
+    @Override
     public Integer getInt(String name) {
         checkAndLoad();
         return config.getInt(name);
@@ -183,6 +203,16 @@ public class Conf implements Config {
     }
 
     @Override
+    public void setInt(String name, int value) {
+        setInt(name, value);
+    }
+
+    @Override
+    public void setInt(ConfigKey name, int value) {
+        setInt(name, value);
+    }
+
+    @Override
     public Long getLong(String name) {
         checkAndLoad();
         return config.getLong(name);
@@ -201,6 +231,16 @@ public class Conf implements Config {
     }
 
     @Override
+    public void setLong(String name, long value) {
+        setLong(name, value);
+    }
+
+    @Override
+    public void setLong(ConfigKey name, long value) {
+        setLong(name, value);
+    }
+
+    @Override
     public Float getFloat(String name) {
         checkAndLoad();
         return config.getFloat(name);
@@ -219,6 +259,16 @@ public class Conf implements Config {
     }
 
     @Override
+    public void setFloat(String name, float value) {
+        setFloat(name, value);
+    }
+
+    @Override
+    public void setFloat(ConfigKey name, float value) {
+        setFloat(name, value);
+    }
+
+    @Override
     public List<String> getList(String name) {
         checkAndLoad();
         return config.getList(name);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9ca5d36e/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java
index 14bfb16..7713418 100644
--- a/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/Config.java
@@ -22,6 +22,11 @@ package org.apache.kerby.config;
 import java.util.List;
 import java.util.Set;
 
+/**
+ * Config API to get configuration properties from resources, like XML, Json,
+ * ini, Java Properties and Map. It doesn't support writing back. It allows to
+ * set configuration properties to ease the preparation of a Config.
+ */
 public interface Config {
     public String getResource();
     public Set<String> getNames();
@@ -29,20 +34,96 @@ public interface Config {
     public String getString(String name);
     public String getString(ConfigKey name);
     public String getString(String name, String defaultValue);
+
+    /**
+     * Set a string value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setString(String name, String value);
+
+    /**
+     * Set a string value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setString(ConfigKey name, String value);
+
     public String getTrimmed(String name);
     public String getTrimmed(ConfigKey name);
     public Boolean getBoolean(String name);
     public Boolean getBoolean(ConfigKey name);
     public Boolean getBoolean(String name, boolean defaultValue);
+
+    /**
+     * Set a boolean value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setBoolean(String name, boolean value);
+
+    /**
+     * Set a boolean value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setBoolean(ConfigKey name, boolean value);
+
     public Integer getInt(String name);
     public Integer getInt(ConfigKey name);
     public Integer getInt(String name, int defaultValue);
+
+    /**
+     * Set an int value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setInt(String name, int value);
+
+    /**
+     * Set an int value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setInt(ConfigKey name, int value);
+
+
     public Long getLong(String name);
     public Long getLong(ConfigKey name);
     public Long getLong(String name, long defaultValue);
+
+    /**
+     * Set a long value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setLong(String name, long value);
+
+    /**
+     * Set a long value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setLong(ConfigKey name, long value);
+
     public Float getFloat(String name);
     public Float getFloat(ConfigKey name);
     public Float getFloat(String name, float defaultValue);
+
+    /**
+     * Set a float value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setFloat(String name, float value);
+
+    /**
+     * Set a float value for the specified property
+     * @param name
+     * @param value
+     */
+    public void setFloat(ConfigKey name, float value);
+
     public List<String> getList(String name);
     public List<String> getList(String name, String[] defaultValue);
     public List<String> getList(ConfigKey name);

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9ca5d36e/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
----------------------------------------------------------------------
diff --git a/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
index 3648b91..9861934 100644
--- a/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
+++ b/lib/kerby-config/src/main/java/org/apache/kerby/config/ConfigImpl.java
@@ -20,13 +20,9 @@
  */
 package org.apache.kerby.config;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.util.*;
 
 public class ConfigImpl implements Config {
-    private static final Logger logger = LoggerFactory.getLogger(Config.class);
 
     private String resource;
     private Map<String, ConfigObject> properties;
@@ -139,6 +135,16 @@ public class ConfigImpl implements Config {
     }
 
     @Override
+    public void setInt(String name, int value) {
+        set(name, String.valueOf(value));
+    }
+
+    @Override
+    public void setInt(ConfigKey name, int value) {
+        set(name.getPropertyKey(), String.valueOf(value));
+    }
+
+    @Override
     public Long getLong(String name) {
         Long result = null;
         String value = getTrimmed(name);
@@ -166,6 +172,16 @@ public class ConfigImpl implements Config {
     }
 
     @Override
+    public void setLong(String name, long value) {
+        set(name, String.valueOf(value));
+    }
+
+    @Override
+    public void setLong(ConfigKey name, long value) {
+        set(name.getPropertyKey(), String.valueOf(value));
+    }
+
+    @Override
     public Float getFloat(String name) {
         Float result = null;
         String value = getTrimmed(name);
@@ -193,6 +209,16 @@ public class ConfigImpl implements Config {
     }
 
     @Override
+    public void setFloat(String name, float value) {
+        set(name, String.valueOf(value));
+    }
+
+    @Override
+    public void setFloat(ConfigKey name, float value) {
+        set(name.getPropertyKey(), String.valueOf(value));
+    }
+
+    @Override
     public Boolean getBoolean(String name) {
         Boolean result = null;
         String value = getTrimmed(name);
@@ -220,6 +246,16 @@ public class ConfigImpl implements Config {
     }
 
     @Override
+    public void setBoolean(String name, boolean value) {
+        set(name, String.valueOf(value));
+    }
+
+    @Override
+    public void setBoolean(ConfigKey name, boolean value) {
+        set(name.getPropertyKey(), String.valueOf(value));
+    }
+
+    @Override
     public List<String> getList(String name) {
         List<String> results = null;
         ConfigObject co = properties.get(name);
@@ -318,6 +354,17 @@ public class ConfigImpl implements Config {
         return result;
     }
 
+
+    @Override
+    public void setString(String name, String value) {
+        set(name, value);
+    }
+
+    @Override
+    public void setString(ConfigKey name, String value) {
+        set(name.getPropertyKey(), value);
+    }
+
     protected void set(String name, String value) {
         ConfigObject co = new ConfigObject(value);
         set(name, co);


Mime
View raw message