@Test public void testMessageFormat3() { assertEquals( "msg. Error at offset 1 : [0xC0->C1C2]", FromHostPrimitiveResult.formatMessage("msg", HexUtils.decodeHex("C0C1C2"), 1, 1, 2)); }
protected static String formatMessage(String message, byte[] hostData, int start, int curPos, int bytesLen) { StringBuilder sb = new StringBuilder(); sb.append(message); if (hostData != null && hostData.length > 0 && curPos < hostData.length && curPos >= start && bytesLen > 0 && start + bytesLen <= hostData.length) { sb.append(". Error at offset "); sb.append(curPos); sb.append(" : [0x"); int spyStart = Math.max(start - SPYBUF_MAX_LEN, 0); appendData(sb, hostData, spyStart, start - spyStart); sb.append(start > spyStart ? "->" : ""); if (curPos > start) { appendData(sb, hostData, start, curPos - start); sb.append("^"); appendData(sb, hostData, curPos, bytesLen + start - curPos); } else { appendData(sb, hostData, start, bytesLen); } int spyStop = Math.min(start + bytesLen + SPYBUF_MAX_LEN, hostData.length); sb.append(spyStop > start + bytesLen ? "<-" : ""); appendData(sb, hostData, start + bytesLen, spyStop - start - bytesLen); sb.append("]"); } else { sb.append(". Position is "); sb.append(curPos); } return sb.toString(); }
FromHostPrimitiveResult { protected static String formatMessage(String message, byte[] hostData, int start, int curPos, int bytesLen) { StringBuilder sb = new StringBuilder(); sb.append(message); if (hostData != null && hostData.length > 0 && curPos < hostData.length && curPos >= start && bytesLen > 0 && start + bytesLen <= hostData.length) { sb.append(". Error at offset "); sb.append(curPos); sb.append(" : [0x"); int spyStart = Math.max(start - SPYBUF_MAX_LEN, 0); appendData(sb, hostData, spyStart, start - spyStart); sb.append(start > spyStart ? "->" : ""); if (curPos > start) { appendData(sb, hostData, start, curPos - start); sb.append("^"); appendData(sb, hostData, curPos, bytesLen + start - curPos); } else { appendData(sb, hostData, start, bytesLen); } int spyStop = Math.min(start + bytesLen + SPYBUF_MAX_LEN, hostData.length); sb.append(spyStop > start + bytesLen ? "<-" : ""); appendData(sb, hostData, start + bytesLen, spyStop - start - bytesLen); sb.append("]"); } else { sb.append(". Position is "); sb.append(curPos); } return sb.toString(); } }
FromHostPrimitiveResult { protected static String formatMessage(String message, byte[] hostData, int start, int curPos, int bytesLen) { StringBuilder sb = new StringBuilder(); sb.append(message); if (hostData != null && hostData.length > 0 && curPos < hostData.length && curPos >= start && bytesLen > 0 && start + bytesLen <= hostData.length) { sb.append(". Error at offset "); sb.append(curPos); sb.append(" : [0x"); int spyStart = Math.max(start - SPYBUF_MAX_LEN, 0); appendData(sb, hostData, spyStart, start - spyStart); sb.append(start > spyStart ? "->" : ""); if (curPos > start) { appendData(sb, hostData, start, curPos - start); sb.append("^"); appendData(sb, hostData, curPos, bytesLen + start - curPos); } else { appendData(sb, hostData, start, bytesLen); } int spyStop = Math.min(start + bytesLen + SPYBUF_MAX_LEN, hostData.length); sb.append(spyStop > start + bytesLen ? "<-" : ""); appendData(sb, hostData, start + bytesLen, spyStop - start - bytesLen); sb.append("]"); } else { sb.append(". Position is "); sb.append(curPos); } return sb.toString(); } FromHostPrimitiveResult(J value);  FromHostPrimitiveResult(String message, byte[] hostData, int start,
            int bytesLen);  FromHostPrimitiveResult(String message, byte[] hostData, int start,
            int curPos, int bytesLen); }
FromHostPrimitiveResult { protected static String formatMessage(String message, byte[] hostData, int start, int curPos, int bytesLen) { StringBuilder sb = new StringBuilder(); sb.append(message); if (hostData != null && hostData.length > 0 && curPos < hostData.length && curPos >= start && bytesLen > 0 && start + bytesLen <= hostData.length) { sb.append(". Error at offset "); sb.append(curPos); sb.append(" : [0x"); int spyStart = Math.max(start - SPYBUF_MAX_LEN, 0); appendData(sb, hostData, spyStart, start - spyStart); sb.append(start > spyStart ? "->" : ""); if (curPos > start) { appendData(sb, hostData, start, curPos - start); sb.append("^"); appendData(sb, hostData, curPos, bytesLen + start - curPos); } else { appendData(sb, hostData, start, bytesLen); } int spyStop = Math.min(start + bytesLen + SPYBUF_MAX_LEN, hostData.length); sb.append(spyStop > start + bytesLen ? "<-" : ""); appendData(sb, hostData, start + bytesLen, spyStop - start - bytesLen); sb.append("]"); } else { sb.append(". Position is "); sb.append(curPos); } return sb.toString(); } FromHostPrimitiveResult(J value);  FromHostPrimitiveResult(String message, byte[] hostData, int start,
            int bytesLen);  FromHostPrimitiveResult(String message, byte[] hostData, int start,
            int curPos, int bytesLen); boolean isSuccess(); String getErrorMessage(); J getValue(); }
FromHostPrimitiveResult { protected static String formatMessage(String message, byte[] hostData, int start, int curPos, int bytesLen) { StringBuilder sb = new StringBuilder(); sb.append(message); if (hostData != null && hostData.length > 0 && curPos < hostData.length && curPos >= start && bytesLen > 0 && start + bytesLen <= hostData.length) { sb.append(". Error at offset "); sb.append(curPos); sb.append(" : [0x"); int spyStart = Math.max(start - SPYBUF_MAX_LEN, 0); appendData(sb, hostData, spyStart, start - spyStart); sb.append(start > spyStart ? "->" : ""); if (curPos > start) { appendData(sb, hostData, start, curPos - start); sb.append("^"); appendData(sb, hostData, curPos, bytesLen + start - curPos); } else { appendData(sb, hostData, start, bytesLen); } int spyStop = Math.min(start + bytesLen + SPYBUF_MAX_LEN, hostData.length); sb.append(spyStop > start + bytesLen ? "<-" : ""); appendData(sb, hostData, start + bytesLen, spyStop - start - bytesLen); sb.append("]"); } else { sb.append(". Position is "); sb.append(curPos); } return sb.toString(); } FromHostPrimitiveResult(J value);  FromHostPrimitiveResult(String message, byte[] hostData, int start,
            int bytesLen);  FromHostPrimitiveResult(String message, byte[] hostData, int start,
            int curPos, int bytesLen); boolean isSuccess(); String getErrorMessage(); J getValue();  }