You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2015/12/21 15:21:02 UTC

[1/2] logging-log4j2 git commit: javadoc fixes

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 03ab8f244 -> 13b0dd879


javadoc fixes


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/78c39982
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/78c39982
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/78c39982

Branch: refs/heads/master
Commit: 78c399827eb601c6db57a479a3c53cbf14b9ccd4
Parents: 03ab8f2
Author: rpopma <rp...@apache.org>
Authored: Sat Dec 19 22:37:08 2015 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Dec 19 22:37:08 2015 +0900

----------------------------------------------------------------------
 .../logging/log4j/util/PropertiesUtil.java      | 68 ++++++++++----------
 1 file changed, 34 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/78c39982/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
index 46df255..77b6497 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
@@ -114,19 +114,27 @@ public final class PropertiesUtil {
     }
 
     /**
-     * Gets the named property as a String.
+     * Gets the named property as a boolean value. If the property matches the string {@code "true"} (case-insensitive),
+     * then it is returned as the boolean value {@code true}. Any other non-{@code null} text in the property is
+     * considered {@code false}.
      *
      * @param name the name of the property to look up
-     * @return the String value of the property or {@code null} if undefined.
+     * @return the boolean value of the property or {@code false} if undefined.
      */
-    public String getStringProperty(final String name) {
-        String prop = null;
-        try {
-            prop = System.getProperty(name);
-        } catch (final SecurityException ignored) {
-            // Ignore
-        }
-        return prop == null ? props.getProperty(name) : prop;
+    public boolean getBooleanProperty(final String name) {
+        return getBooleanProperty(name, false);
+    }
+
+    /**
+     * Gets the named property as a boolean value.
+     *
+     * @param name the name of the property to look up
+     * @param defaultValue the default value to use if the property is undefined
+     * @return the boolean value of the property or {@code defaultValue} if undefined.
+     */
+    public boolean getBooleanProperty(final String name, final boolean defaultValue) {
+        final String prop = getStringProperty(name);
+        return (prop == null) ? defaultValue : "true".equalsIgnoreCase(prop);
     }
 
     /**
@@ -188,41 +196,33 @@ public final class PropertiesUtil {
      * Gets the named property as a String.
      *
      * @param name the name of the property to look up
-     * @param defaultValue the default value to use if the property is undefined
-     * @return the String value of the property or {@code defaultValue} if undefined.
-     */
-    public String getStringProperty(final String name, final String defaultValue) {
-        final String prop = getStringProperty(name);
-        return (prop == null) ? defaultValue : prop;
-    }
-
-    /**
-     * Gets the named property as a boolean value. If the property matches the string {@code "true"} (case-insensitive),
-     * then it is returned as the boolean value {@code true}. Any other non-{@code null} text in the property is
-     * considered {@code false}.
-     *
-     * @param name the name of the property to look up
-     * @return the boolean value of the property or {@code false} if undefined.
+     * @return the String value of the property or {@code null} if undefined.
      */
-    public boolean getBooleanProperty(final String name) {
-        return getBooleanProperty(name, false);
+    public String getStringProperty(final String name) {
+        String prop = null;
+        try {
+            prop = System.getProperty(name);
+        } catch (final SecurityException ignored) {
+            // Ignore
+        }
+        return prop == null ? props.getProperty(name) : prop;
     }
 
     /**
-     * Gets the named property as a boolean value.
+     * Gets the named property as a String.
      *
      * @param name the name of the property to look up
      * @param defaultValue the default value to use if the property is undefined
-     * @return the boolean value of the property or {@code defaultValue} if undefined.
+     * @return the String value of the property or {@code defaultValue} if undefined.
      */
-    public boolean getBooleanProperty(final String name, final boolean defaultValue) {
+    public String getStringProperty(final String name, final String defaultValue) {
         final String prop = getStringProperty(name);
-        return (prop == null) ? defaultValue : "true".equalsIgnoreCase(prop);
+        return (prop == null) ? defaultValue : prop;
     }
 
     /**
      * Return the system properties or an empty Properties object if an error occurs.
-     * 
+     *
      * @return The system properties.
      */
     public static Properties getSystemProperties() {
@@ -238,7 +238,7 @@ public final class PropertiesUtil {
     /**
      * Extracts properties that start with or are equals to the specific prefix and returns them in a new Properties
      * object with the prefix removed.
-     * 
+     *
      * @param properties The Properties to evaluate.
      * @param prefix The prefix to extract.
      * @return The subset of properties.
@@ -266,7 +266,7 @@ public final class PropertiesUtil {
 
         return subset;
     }
-    
+
     /**
      * Returns true if system properties tell us we are running on Windows.
      * @return true if system properties tell us we are running on Windows.


[2/2] logging-log4j2 git commit: LOG4J2-1080 added method getDoubleProperty

Posted by rp...@apache.org.
LOG4J2-1080 added method getDoubleProperty


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/13b0dd87
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/13b0dd87
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/13b0dd87

Branch: refs/heads/master
Commit: 13b0dd8794f52facddb4a27ba7612ddbf7abef4b
Parents: 78c3998
Author: rpopma <rp...@apache.org>
Authored: Sat Dec 19 22:40:05 2015 +0900
Committer: rpopma <rp...@apache.org>
Committed: Sat Dec 19 22:40:05 2015 +0900

----------------------------------------------------------------------
 .../logging/log4j/util/PropertiesUtil.java      | 27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/13b0dd87/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
index 77b6497..ff4389c 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
@@ -138,6 +138,33 @@ public final class PropertiesUtil {
     }
 
     /**
+     * Gets the named property as a double.
+     *
+     * @param name the name of the property to look up
+     * @param defaultValue the default value to use if the property is undefined
+     * @return the parsed double value of the property or {@code defaultValue} if it was undefined or could not be parsed.
+     */
+    public double getDoubleProperty(final String name, final double defaultValue) {
+        String prop = null;
+        try {
+            prop = System.getProperty(name);
+        } catch (final SecurityException ignored) {
+            // Ignore
+        }
+        if (prop == null) {
+            prop = props.getProperty(name);
+        }
+        if (prop != null) {
+            try {
+                return Double.parseDouble(prop);
+            } catch (final Exception ignored) {
+                return defaultValue;
+            }
+        }
+        return defaultValue;
+    }
+
+    /**
      * Gets the named property as an integer.
      *
      * @param name the name of the property to look up