/** 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, ", "); }
@Nullable protected String getIndexedDescription( final int tagType, final int baseIndex, @NotNull String... descriptions) { final Integer index = _directory.getInteger(tagType); if (index == null) return null; final int arrayIndex = index - baseIndex; if (arrayIndex >= 0 && arrayIndex < descriptions.length) { String description = descriptions[arrayIndex]; if (description != null) return description; } return "Unknown (" + index + ")"; }
@Nullable protected String getFormattedInt(final int tagType, @NotNull final String format) { Integer value = _directory.getInteger(tagType); if (value == null) return null; return String.format(format, value); }