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 15:07:25 UTC
[incubator-plc4x] branch master updated: pullup dump() method to
ByteReadable to easily dump every ByteReadable as hex
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 cbd4579 pullup dump() method to ByteReadable to easily dump every ByteReadable as hex
cbd4579 is described below
commit cbd4579acee04723421e3305479a5fede703022f
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Sat Feb 17 16:07:21 2018 +0100
pullup dump() method to ByteReadable to easily dump every ByteReadable
as hex
---
.../org/apache/plc4x/java/ads/api/commands/types/Data.java | 10 ----------
.../java/org/apache/plc4x/java/ads/api/util/ByteReadable.java | 10 ++++++++++
2 files changed, 10 insertions(+), 10 deletions(-)
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 6c9de94..12872e5 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,11 +18,8 @@
*/
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;
@@ -47,13 +44,6 @@ public class Data extends ByteValue {
return new Data(value.getBytes(charset));
}
- public String dump() throws IOException {
- try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
- HexDump.dump(value, 0, byteArrayOutputStream, 0);
- return toString() + HexDump.EOL + byteArrayOutputStream.toString();
- }
- }
-
@Override
public String toString() {
// TODO: maybe we could find a way to implement this to string
diff --git a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteReadable.java b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteReadable.java
index feadb17..0d9ac81 100644
--- a/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteReadable.java
+++ b/plc4j/protocols/ads/src/main/java/org/apache/plc4x/java/ads/api/util/ByteReadable.java
@@ -19,6 +19,10 @@
package org.apache.plc4x.java.ads.api.util;
import io.netty.buffer.ByteBuf;
+import org.apache.commons.io.HexDump;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
@FunctionalInterface
public interface ByteReadable extends LengthSupplier {
@@ -36,4 +40,10 @@ public interface ByteReadable extends LengthSupplier {
return getBytes().length;
}
+ default String dump() throws IOException {
+ try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
+ HexDump.dump(getBytes(), 0, byteArrayOutputStream, 0);
+ return toString() + HexDump.EOL + byteArrayOutputStream.toString();
+ }
+ }
}
--
To stop receiving notification emails like this one, please contact
sruehl@apache.org.