@Test public void testGetTagValueAsString() throws Exception { Assertions .assertThat( (String) ReflectionTestUtils.invokeMethod(TlvUtil.class, "getTagValueAsString", EmvTags.ACQUIRER_IDENTIFIER, "56".getBytes())).isEqualTo("NUMERIC"); Assertions.assertThat( (String) ReflectionTestUtils.invokeMethod(TlvUtil.class, "getTagValueAsString", EmvTags.ISSUER_COUNTRY_CODE_ALPHA3, "56".getBytes())).isEqualTo("=56"); Assertions.assertThat( (String) ReflectionTestUtils.invokeMethod(TlvUtil.class, "getTagValueAsString", EmvTags.APP_DISCRETIONARY_DATA, "56".getBytes())).isEqualTo("BINARY"); Assertions.assertThat( (String) ReflectionTestUtils.invokeMethod(TlvUtil.class, "getTagValueAsString", EmvTags.BANK_IDENTIFIER_CODE, "56".getBytes())).isEqualTo("=56"); Assertions .assertThat((String) ReflectionTestUtils.invokeMethod(TlvUtil.class, "getTagValueAsString", EmvTags.DDOL, "56".getBytes())) .isEqualTo(""); }
private static String getTagValueAsString(final ITag tag, final byte[] value) { StringBuilder buf = new StringBuilder(); switch (tag.getTagValueType()) { case TEXT: buf.append("="); buf.append(new String(value)); break; case NUMERIC: buf.append("NUMERIC"); break; case BINARY: buf.append("BINARY"); break; case MIXED: buf.append("="); buf.append(getSafePrintChars(value)); break; case DOL: buf.append(""); break; default: break; } return buf.toString(); }
TlvUtil { private static String getTagValueAsString(final ITag tag, final byte[] value) { StringBuilder buf = new StringBuilder(); switch (tag.getTagValueType()) { case TEXT: buf.append("="); buf.append(new String(value)); break; case NUMERIC: buf.append("NUMERIC"); break; case BINARY: buf.append("BINARY"); break; case MIXED: buf.append("="); buf.append(getSafePrintChars(value)); break; case DOL: buf.append(""); break; default: break; } return buf.toString(); } }
TlvUtil { private static String getTagValueAsString(final ITag tag, final byte[] value) { StringBuilder buf = new StringBuilder(); switch (tag.getTagValueType()) { case TEXT: buf.append("="); buf.append(new String(value)); break; case NUMERIC: buf.append("NUMERIC"); break; case BINARY: buf.append("BINARY"); break; case MIXED: buf.append("="); buf.append(getSafePrintChars(value)); break; case DOL: buf.append(""); break; default: break; } return buf.toString(); } private  TlvUtil(); }
TlvUtil { private static String getTagValueAsString(final ITag tag, final byte[] value) { StringBuilder buf = new StringBuilder(); switch (tag.getTagValueType()) { case TEXT: buf.append("="); buf.append(new String(value)); break; case NUMERIC: buf.append("NUMERIC"); break; case BINARY: buf.append("BINARY"); break; case MIXED: buf.append("="); buf.append(getSafePrintChars(value)); break; case DOL: buf.append(""); break; default: break; } return buf.toString(); } private  TlvUtil(); static String getFormattedTagAndLength(final byte[] data, final int indentLength); static TLV getNextTLV(final TLVInputStream stream); static List<TagAndLength> parseTagAndLength(final byte[] data); static String prettyPrintAPDUResponse(final byte[] data); static List<TLV> getlistTLV(final byte[] pData, final ITag pTag, final boolean pAdd); static List<TLV> getlistTLV(final byte[] pData, final ITag... pTag); static byte[] getValue(final byte[] pData, final ITag... pTag); static String prettyPrintAPDUResponse(final byte[] data, final int indentLength); static String getSpaces(final int length); static String prettyPrintHex(final String in, final int indent); static String prettyPrintHex(final byte[] data); static String prettyPrintHex(final String in, final int indent, final boolean wrapLines); static String getSafePrintChars(final byte[] byteArray); static String getSafePrintChars(final byte[] byteArray, final int startPos, final int length); static int getLength(final List<TagAndLength> pList); }
TlvUtil { private static String getTagValueAsString(final ITag tag, final byte[] value) { StringBuilder buf = new StringBuilder(); switch (tag.getTagValueType()) { case TEXT: buf.append("="); buf.append(new String(value)); break; case NUMERIC: buf.append("NUMERIC"); break; case BINARY: buf.append("BINARY"); break; case MIXED: buf.append("="); buf.append(getSafePrintChars(value)); break; case DOL: buf.append(""); break; default: break; } return buf.toString(); } private  TlvUtil(); static String getFormattedTagAndLength(final byte[] data, final int indentLength); static TLV getNextTLV(final TLVInputStream stream); static List<TagAndLength> parseTagAndLength(final byte[] data); static String prettyPrintAPDUResponse(final byte[] data); static List<TLV> getlistTLV(final byte[] pData, final ITag pTag, final boolean pAdd); static List<TLV> getlistTLV(final byte[] pData, final ITag... pTag); static byte[] getValue(final byte[] pData, final ITag... pTag); static String prettyPrintAPDUResponse(final byte[] data, final int indentLength); static String getSpaces(final int length); static String prettyPrintHex(final String in, final int indent); static String prettyPrintHex(final byte[] data); static String prettyPrintHex(final String in, final int indent, final boolean wrapLines); static String getSafePrintChars(final byte[] byteArray); static String getSafePrintChars(final byte[] byteArray, final int startPos, final int length); static int getLength(final List<TagAndLength> pList);  }