You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2018/02/17 01:30:01 UTC

[incubator-plc4x] branch master updated: added dump() method to ADSData to better analyse data.

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-plc4x.git


The following commit(s) were added to refs/heads/master by this push:
     new 5d18f53  added dump() method to ADSData to better analyse data.
5d18f53 is described below

commit 5d18f531f051b8c5477e1f1188de197394bd65d2
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Sat Feb 17 02:28:54 2018 +0100

    added dump() method to ADSData to better analyse data.
---
 .../org/apache/plc4x/java/ads/api/commands/types/Data.java  | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
index e4008a4..7b83308 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/commands/types/Data.java
@@ -18,8 +18,11 @@
  */
 package org.apache.plc4x.java.ads.api.commands.types;
 
+import org.apache.commons.io.HexDump;
 import org.apache.plc4x.java.ads.api.util.ByteValue;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.nio.charset.Charset;
 
 import static java.util.Objects.requireNonNull;
@@ -44,6 +47,16 @@ public class Data extends ByteValue {
         return new Data(value.getBytes(charset));
     }
 
+    public String dump() {
+        try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
+            HexDump.dump(value, 0, byteArrayOutputStream, 0);
+            byteArrayOutputStream.flush();
+            return toString() + HexDump.EOL + byteArrayOutputStream.toString();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
     @Override
     public String toString() {
         return "Data{" + value.length + "bytes} ";

-- 
To stop receiving notification emails like this one, please contact
sruehl@apache.org.