ValueLabelRenderer () { return new LabelRenderer() { @Override public String calcLabel(ValueDescriptor valueDescriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener) { Value value = valueDescriptor.getValue(); if (value == null) { return "null"; } StringBuilder buf = new StringBuilder("0b"); int prefixLength = buf.length(); String valueStr = ""; if (value instanceof ByteValue) { valueStr = Integer.toBinaryString(0xff & ((ByteValue)value).byteValue()); } else if (value instanceof ShortValue) { valueStr = Integer.toBinaryString(0xffff & ((ShortValue)value).shortValue()); } else if (value instanceof IntegerValue) { valueStr = Integer.toBinaryString(((PrimitiveValue)value).intValue()); } else if (value instanceof LongValue) { valueStr = Long.toBinaryString(((LongValue)value).longValue()); } else { LOG.error("Unsupported value " + value); } // add leading zeros int remainder = valueStr.length() % 8; if (remainder != 0) { buf.append("0".repeat(8 - remainder)); } buf.append(valueStr); // group by 8 for (int i = buf.length() - 8; i > prefixLength; i -= 8) { buf.insert(i, '_'); } return buf.toString(); } }; }