karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf-decanter] branch master updated: [KARAF-6242] Improve Split and Regex parser by casting data
Date Wed, 17 Apr 2019 04:13:08 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf-decanter.git


The following commit(s) were added to refs/heads/master by this push:
     new dbbbb82  [KARAF-6242] Improve Split and Regex parser by casting data
     new 829c066  Merge pull request #78 from fpapon/KARAF-6242
dbbbb82 is described below

commit dbbbb829592fa2348f80c3d049de848f538e77d0
Author: Francois Papon <francois.papon@openobject.fr>
AuthorDate: Tue Apr 16 21:14:57 2019 +0400

    [KARAF-6242] Improve Split and Regex parser by casting data
---
 .../apache/karaf/decanter/parser/regex/RegexParser.java    | 13 +++++++++++++
 .../apache/karaf/decanter/parser/split/SplitParser.java    | 14 ++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/parser/regex/src/main/java/org/apache/karaf/decanter/parser/regex/RegexParser.java
b/parser/regex/src/main/java/org/apache/karaf/decanter/parser/regex/RegexParser.java
index e053ca9..e8f5cea 100644
--- a/parser/regex/src/main/java/org/apache/karaf/decanter/parser/regex/RegexParser.java
+++ b/parser/regex/src/main/java/org/apache/karaf/decanter/parser/regex/RegexParser.java
@@ -77,6 +77,19 @@ public class RegexParser implements Parser {
             }
             if (matcher.find()) {
                 for (int i = 0; i < matcher.groupCount(); i++) {
+                    try {
+                        data.put(keysArray[i], Integer.parseInt(matcher.group(i + 1)));
+                        continue;
+                    } catch (Exception e) {
+                        // nothing to do
+                    }
+
+                    try {
+                        data.put(keysArray[i], Long.parseLong(matcher.group(i + 1)));
+                        continue;
+                    } catch (Exception e) {
+                        // nothing to do
+                    }
                     data.put(keysArray[i], matcher.group(i + 1));
                 }
             }
diff --git a/parser/split/src/main/java/org/apache/karaf/decanter/parser/split/SplitParser.java
b/parser/split/src/main/java/org/apache/karaf/decanter/parser/split/SplitParser.java
index e0b0ba4..6f2c9b5 100644
--- a/parser/split/src/main/java/org/apache/karaf/decanter/parser/split/SplitParser.java
+++ b/parser/split/src/main/java/org/apache/karaf/decanter/parser/split/SplitParser.java
@@ -72,6 +72,20 @@ public class SplitParser implements Parser {
                 }
             }
             for (int i = 0; i < valuesArray.length; i++) {
+                try {
+                    map.put(keysArray[i], Integer.parseInt(valuesArray[i]));
+                    continue;
+                } catch (Exception e) {
+                    // nothing to do
+                }
+
+                try {
+                    map.put(keysArray[i], Long.parseLong(valuesArray[i]));
+                    continue;
+                } catch (Exception e) {
+                    // nothing to do
+                }
+                // if not integer and long value
                 map.put(keysArray[i], valuesArray[i]);
             }
         }


Mime
View raw message