aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2018-11-14 14:05:42 +0100
committersteven luong <sluong@cisco.com>2019-05-03 20:52:11 +0000
commitc2f8265c1db9daccd3c39e717e55c071e50132c3 (patch)
tree99d224d46b8d9a0c918842f4487ebaceca04b1f4
parent1161ddaa6f7136cfbc541d4179420308a590d36e (diff)
VPP-1477: Replace DatatypeConverter.printHexBinary with bytesToHex
As of Java 11 javax.xml.bind.DatatypeConverter is no longer part of standard Java distribution, therefore it is replaced by equivalent method. Change-Id: I51726d0d0d02782bd3bb1dbdc54df5bd63bd8f15 Signed-off-by: Michal Cmarada <mcmarada@cisco.com> (cherry picked from commit feb7092544a9e49370037b6d90b43e98c65e7a41)
-rw-r--r--extras/japi/java/jvpp-core/io/fd/vpp/jvpp/core/examples/L2AclExample.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/extras/japi/java/jvpp-core/io/fd/vpp/jvpp/core/examples/L2AclExample.java b/extras/japi/java/jvpp-core/io/fd/vpp/jvpp/core/examples/L2AclExample.java
index f89043a3b0a..9a17136a6d9 100644
--- a/extras/japi/java/jvpp-core/io/fd/vpp/jvpp/core/examples/L2AclExample.java
+++ b/extras/japi/java/jvpp-core/io/fd/vpp/jvpp/core/examples/L2AclExample.java
@@ -34,7 +34,6 @@ import io.fd.vpp.jvpp.core.dto.ClassifyTableInfoReply;
import io.fd.vpp.jvpp.core.dto.InputAclSetInterface;
import io.fd.vpp.jvpp.core.dto.InputAclSetInterfaceReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade;
-import javax.xml.bind.DatatypeConverter;
/**
* <p>Tests L2 ACL creation and read.<br> Equivalent to the following vppctl commands:<br>
@@ -50,6 +49,8 @@ import javax.xml.bind.DatatypeConverter;
public class L2AclExample {
private static final int LOCAL0_IFACE_ID = 0;
+ private static final char[] hexArray = "0123456789ABCDEF".toCharArray();
+
private static ClassifyAddDelTable createClassifyTable() {
ClassifyAddDelTable request = new ClassifyAddDelTable();
@@ -67,6 +68,16 @@ public class L2AclExample {
return request;
}
+ private static String bytesToHex(byte[] bytes) {
+ char[] hexChars = new char[bytes.length * 2];
+ for ( int j = 0; j < bytes.length; j++ ) {
+ int v = bytes[j] & 0xFF;
+ hexChars[j * 2] = hexArray[v >>> 4];
+ hexChars[j * 2 + 1] = hexArray[v & 0x0F];
+ }
+ return new String(hexChars);
+ }
+
private static ClassifyTableInfo createClassifyTableInfoRequest(final int tableId) {
ClassifyTableInfo request = new ClassifyTableInfo();
request.tableId = tableId;
@@ -120,7 +131,7 @@ public class L2AclExample {
private static void print(final ClassifyTableInfoReply reply) {
System.out.println(reply);
if (reply != null) {
- System.out.println("Mask hex: " + DatatypeConverter.printHexBinary(reply.mask));
+ System.out.println("Mask hex: " + bytesToHex(reply.mask));
}
}
@@ -132,7 +143,7 @@ public class L2AclExample {
System.out.println(reply);
reply.classifySessionDetails.forEach(detail -> {
System.out.println(detail);
- System.out.println("Match hex: " + DatatypeConverter.printHexBinary(detail.match));
+ System.out.println("Match hex: " + bytesToHex(detail.match));
});
}