protected static byte[] charBufferToBytes(CharBuffer charBuffer, String characterSet) throws CharacterCodingException { Charset charset = Charset.forName(characterSet); CharsetEncoder encoder = charset.newEncoder(); ByteBuffer byteBuffer = encoder.encode(charBuffer); return BufferTools.copyBuffer(byteBuffer.array(), 0, byteBuffer.limit()); } }
private int unpackExtendedHeader(byte[] bytes, int offset) { extendedHeaderLength = BufferTools.unpackSynchsafeInteger(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]) + 4; extendedHeaderData = BufferTools.copyBuffer(bytes, offset + 4, extendedHeaderLength); return extendedHeaderLength; }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { text = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, bytes.length - 1)); }
protected final void unpackFrame(byte[] buffer, int offset) throws InvalidDataException { int dataOffset = unpackHeader(buffer, offset); sanityCheckUnpackedHeader(); data = BufferTools.copyBuffer(buffer, dataOffset, dataLength); }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { String filetype; try { filetype = BufferTools.byteBufferToString(bytes, 1, 3); } catch (UnsupportedEncodingException e) { filetype = "unknown"; } mimeType = "image/" + filetype.toLowerCase(); pictureType = bytes[4]; int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 5, bytes[0]); if (marker >= 0) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 5, marker - 5)); marker += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker = 1; } imageData = BufferTools.copyBuffer(bytes, marker, bytes.length - marker); } }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { try { language = BufferTools.byteBufferToString(bytes, 1, 3); } catch (UnsupportedEncodingException e) { language = ""; } int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 4, bytes[0]); if (marker >= 4) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 4, marker - 4)); marker += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker = 4; } comment = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, marker, bytes.length - marker)); }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { int marker = BufferTools.indexOfTerminator(bytes, 1, 1); if (marker >= 0) { try { mimeType = BufferTools.byteBufferToString(bytes, 1, marker - 1); } catch (UnsupportedEncodingException e) { mimeType = "image/unknown"; } } else { mimeType = "image/unknown"; } pictureType = bytes[marker + 1]; marker += 2; int marker2 = BufferTools.indexOfTerminatorForEncoding(bytes, marker, bytes[0]); if (marker2 >= 0) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, marker, marker2 - marker)); marker2 += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker2 = marker; } imageData = BufferTools.copyBuffer(bytes, marker2, bytes.length - marker2); }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 1, bytes[0]); if (marker >= 0) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, marker - 1)); marker += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker = 1; } try { url = BufferTools.byteBufferToString(bytes, marker, bytes.length - marker); } catch (UnsupportedEncodingException e) { url = ""; } }
protected static byte[] charBufferToBytes(CharBuffer charBuffer, String characterSet) throws CharacterCodingException { Charset charset = Charset.forName(characterSet); CharsetEncoder encoder = charset.newEncoder(); ByteBuffer byteBuffer = encoder.encode(charBuffer); return BufferTools.copyBuffer(byteBuffer.array(), 0, byteBuffer.limit()); } }
private int unpackExtendedHeader(byte[] bytes, int offset) { extendedHeaderLength = BufferTools.unpackSynchsafeInteger(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]) + 4; extendedHeaderData = BufferTools.copyBuffer(bytes, offset + 4, extendedHeaderLength); return extendedHeaderLength; }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { text = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, bytes.length - 1)); }
protected final void unpackFrame(byte[] buffer, int offset) throws InvalidDataException { int dataOffset = unpackHeader(buffer, offset); sanityCheckUnpackedHeader(); data = BufferTools.copyBuffer(buffer, dataOffset, dataLength); }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { String filetype; try { filetype = BufferTools.byteBufferToString(bytes, 1, 3); } catch (UnsupportedEncodingException e) { filetype = "unknown"; } mimeType = "image/" + filetype.toLowerCase(); pictureType = bytes[4]; int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 5, bytes[0]); if (marker >= 0) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 5, marker - 5)); marker += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker = 1; } imageData = BufferTools.copyBuffer(bytes, marker, bytes.length - marker); } }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { try { language = BufferTools.byteBufferToString(bytes, 1, 3); } catch (UnsupportedEncodingException e) { language = ""; } int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 4, bytes[0]); if (marker >= 4) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 4, marker - 4)); marker += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker = 4; } comment = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, marker, bytes.length - marker)); }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { int marker = BufferTools.indexOfTerminator(bytes, 1, 1); if (marker >= 0) { try { mimeType = BufferTools.byteBufferToString(bytes, 1, marker - 1); } catch (UnsupportedEncodingException e) { mimeType = "image/unknown"; } } else { mimeType = "image/unknown"; } pictureType = bytes[marker + 1]; marker += 2; int marker2 = BufferTools.indexOfTerminatorForEncoding(bytes, marker, bytes[0]); if (marker2 >= 0) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, marker, marker2 - marker)); marker2 += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker2 = marker; } imageData = BufferTools.copyBuffer(bytes, marker2, bytes.length - marker2); }
@Override protected void unpackFrameData(byte[] bytes) throws InvalidDataException { int marker = BufferTools.indexOfTerminatorForEncoding(bytes, 1, bytes[0]); if (marker >= 0) { description = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, marker - 1)); marker += description.getTerminator().length; } else { description = new EncodedText(bytes[0], ""); marker = 1; } try { url = BufferTools.byteBufferToString(bytes, marker, bytes.length - marker); } catch (UnsupportedEncodingException e) { url = ""; } }