private void showCustomTag(StringBuffer buffer) { buffer.append("Custom Tag\n"); byte[] bytes = mp3file.getCustomTag(); if (bytes == null) { buffer.append(" NONE!\n"); } else { int length = Math.min(bytes.length, MAX_CUSTOM_TAG_BYTES_TO_SHOW); try { String s = BufferTools.byteBufferToString(bytes, 0, length); showLastField(buffer, "Data", BufferTools.asciiOnly(s), bytes.length > MAX_CUSTOM_TAG_BYTES_TO_SHOW ? "..." : null); } catch (UnsupportedEncodingException e) { buffer.append(" ?\n"); } } }
private void updateCustomTag() { byte[] existingCustomTag = mp3file.getCustomTag(); byte[] newCustomTag = null; if (keepCustomTag && existingCustomTag != null && existingCustomTag.length > 0) { if (customTag != null && customTag.length() > 0) { EncodedText customTagEncodedText = new EncodedText(customTag); byte bytes[] = customTagEncodedText.toBytes(true); int newLength = existingCustomTag.length + bytes.length; newCustomTag = new byte[newLength]; BufferTools.copyIntoByteBuffer(existingCustomTag, 0, existingCustomTag.length, newCustomTag, 0); BufferTools.copyIntoByteBuffer(bytes, 0, bytes.length, newCustomTag, existingCustomTag.length); } else { newCustomTag = mp3file.getCustomTag(); } } else if (customTag != null && customTag.length() > 0) { EncodedText customTagEncodedText = new EncodedText(customTag); newCustomTag = customTagEncodedText.toBytes(true); } mp3file.setCustomTag(newCustomTag); }
private void catalogCustomTag(StringBuffer cat) { byte[] bytes = mp3file.getCustomTag(); if (bytes == null) { catalogLastField(cat, ""); } else { int length = Math.min(bytes.length, MAX_CUSTOM_TAG_BYTES_TO_SHOW); try { String s = BufferTools.byteBufferToString(bytes, 0, length); catalogLastField(cat, BufferTools.asciiOnly(s)); } catch (UnsupportedEncodingException e) { catalogLastField(cat, ""); } } }
} else { boolean hasCustomTag = mp3file.hasCustomTag(); if (hasCustomTag && mp3file.getCustomTag().length > CUSTOM_TAG_WARNING_THRESHOLD) { printError("WARNING processing \"" + FileUtils.extractFilename(filename) + "\" - custom tag is " + mp3file.getCustomTag().length + " bytes, potential corrupt file");