/** LSB first. Labels may be null, a String, or a String[2] with (low label,high label) values. */ @Nullable protected String getBitFlagDescription(final int tagType, @NotNull final Object... labels) { Integer value = _directory.getInteger(tagType); if (value == null) return null; List<String> parts = new ArrayList<String>(); int bitIndex = 0; while (labels.length > bitIndex) { Object labelObj = labels[bitIndex]; if (labelObj != null) { boolean isBitSet = (value & 1) == 1; if (labelObj instanceof String[]) { String[] labelPair = (String[]) labelObj; assert (labelPair.length == 2); parts.add(labelPair[isBitSet ? 1 : 0]); } else if (isBitSet && labelObj instanceof String) { parts.add((String) labelObj); } } value >>= 1; bitIndex++; } return StringUtil.join(parts, ", "); }