nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joew...@apache.org
Subject [04/50] [abbrv] incubator-nifi git commit: Encapsulating the rendering of a JsonPath result within JsonUtils
Date Mon, 02 Mar 2015 04:03:43 GMT
Encapsulating the rendering of a JsonPath result within JsonUtils


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/9a5b6d5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/9a5b6d5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/9a5b6d5b

Branch: refs/heads/develop
Commit: 9a5b6d5ba234c471df8faefb0ebf9470a68bebb5
Parents: c88b427
Author: Aldrin Piri <aldrinpiri@gmail.com>
Authored: Tue Feb 17 21:29:40 2015 -0500
Committer: Aldrin Piri <aldrinpiri@gmail.com>
Committed: Tue Feb 17 21:29:40 2015 -0500

----------------------------------------------------------------------
 .../apache/nifi/processors/standard/EvaluateJsonPath.java | 10 +---------
 .../org/apache/nifi/processors/standard/SplitJson.java    |  7 +------
 .../apache/nifi/processors/standard/util/JsonUtils.java   | 10 +++++++++-
 3 files changed, 11 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9a5b6d5b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java
b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java
index 3a64a34..d79a6de 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java
@@ -215,7 +215,7 @@ public class EvaluateJsonPath extends AbstractProcessor {
                     }
                 }
 
-                final String resultRepresentation = getResultRepresentation(resultHolder.get());
+                final String resultRepresentation = JsonUtils.getResultRepresentation(resultHolder.get());
                 switch (destination) {
                     case DESTINATION_ATTRIBUTE:
                         jsonPathResults.put(jsonPathAttrKey, resultRepresentation);
@@ -237,12 +237,4 @@ public class EvaluateJsonPath extends AbstractProcessor {
         }
     }
 
-    private static String getResultRepresentation(Object jsonPathResult) {
-        if (JsonUtils.isJsonScalar(jsonPathResult)) {
-            return jsonPathResult.toString();
-        }
-        return JsonUtils.JSON_PROVIDER.toJson(jsonPathResult);
-    }
-
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9a5b6d5b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SplitJson.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SplitJson.java
b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SplitJson.java
index c2b520c..78e1b2a 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SplitJson.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SplitJson.java
@@ -129,12 +129,7 @@ public class SplitJson extends AbstractProcessor {
             split = processSession.write(split, new OutputStreamCallback() {
                 @Override
                 public void process(OutputStream out) throws IOException {
-                    String resultSegmentContent;
-                    if (JsonUtils.isJsonScalar(resultSegment)) {
-                        resultSegmentContent = resultSegment.toString();
-                    } else {
-                        resultSegmentContent = JsonUtils.JSON_PROVIDER.toJson(resultSegment);
-                    }
+                    String resultSegmentContent = JsonUtils.getResultRepresentation(resultSegment);
                     out.write(resultSegmentContent.getBytes(StandardCharsets.UTF_8));
                 }
             });

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9a5b6d5b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonUtils.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonUtils.java
b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonUtils.java
index 6f97207..2174c1e 100644
--- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonUtils.java
+++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/JsonUtils.java
@@ -46,7 +46,7 @@ import java.util.Map;
  */
 public class JsonUtils {
 
-    public static final JsonProvider JSON_PROVIDER = Configuration.defaultConfiguration().jsonProvider();
+    static final JsonProvider JSON_PROVIDER = Configuration.defaultConfiguration().jsonProvider();
 
     public static final Validator JSON_PATH_VALIDATOR = new Validator() {
         @Override
@@ -116,4 +116,12 @@ public class JsonUtils {
         return !(obj instanceof Map || obj instanceof List);
     }
 
+
+    public static String getResultRepresentation(Object jsonPathResult) {
+        if (JsonUtils.isJsonScalar(jsonPathResult)) {
+            return jsonPathResult.toString();
+        }
+        return JSON_PROVIDER.toJson(jsonPathResult);
+    }
+
 }


Mime
View raw message