Value { public String toString() { decode(); StringBuilder stringBuilder = new StringBuilder(); if (isList()) { Object[] list = (Object[]) value; if (list.length == 2) { stringBuilder.append("[ "); Value key = new Value(list[0]); byte[] keyNibbles = CompactEncoder.binToNibblesNoTerminator(key.asBytes()); String keyString = ByteUtil.nibblesToPrettyString(keyNibbles); stringBuilder.append(keyString); stringBuilder.append(","); Value val = new Value(list[1]); stringBuilder.append(val.toString()); stringBuilder.append(" ]"); return stringBuilder.toString(); } stringBuilder.append(" ["); for (int i = 0; i < list.length; ++i) { Value val = new Value(list[i]); if (val.isString() || val.isEmpty()) { stringBuilder.append("'").append(val.toString()).append("'"); } else { stringBuilder.append(val.toString()); } if (i < list.length - 1) stringBuilder.append(", "); } stringBuilder.append("] "); return stringBuilder.toString(); } else if (isEmpty()) { return ""; } else if (isBytes()) { StringBuilder output = new StringBuilder(); if (isHashCode()) { output.append(toHexString(asBytes())); } else if (isReadableString()) { output.append("'"); for (byte oneByte : asBytes()) { if (oneByte < 16) { output.append("\\x").append(ByteUtil.oneByteToHexString(oneByte)); } else { output.append(Character.valueOf((char) oneByte)); } } output.append("'"); return output.toString(); } return toHexString(this.asBytes()); } else if (isString()) { return asString(); } return "Unexpected type"; } Value();  Value(Object obj); static Value fromRlpEncoded(byte[] data); void init(byte[] rlp); Value withHash(byte[] hash); Object asObj(); List<Object> asList(); int asInt(); long asLong(); BigInteger asBigInt(); String asString(); byte[] asBytes(); String getHex(); byte[] getData(); int[] asSlice(); Value get(int index); void decode(); byte[] encode(); byte[] hash(); boolean cmp(Value o); boolean isList(); boolean isString(); boolean isInt(); boolean isLong(); boolean isBigInt(); boolean isBytes(); boolean isReadableString(); boolean isHexString(); boolean isHashCode(); boolean isNull(); boolean isEmpty(); int length(); String toString(); int countBranchNodes();  }
@Test public void testToString() { Value val = new Value(Hex.decode("fe")); assertEquals("fe", val.toString()); assertEquals("fe", Hex.toHexString(val.asBytes())); }