@Override public String toString() { final byte[] uncompressed = getUncompressedContent(); final byte[] compressed = getCompressedContent(); final String raw = Arrays.toString(Arrays.copyOf(uncompressed, Math.min(5, uncompressed.length))); final String comp = Arrays.toString(Arrays.copyOf(compressed, Math.min(5, compressed.length))); return String.format("compression method=%s, content type=%s, id=%d, raw size=%d, compressed size=%d, raw=%s, comp=%s.", getCompressionMethod().name(), getContentType().name(), getContentId(), getUncompressedContentSize(), getCompressedContentSize(), raw, comp); } }
private void doWrite(final OutputStream outputStream) throws IOException { outputStream.write(getCompressionMethod().getMethodId()); outputStream.write(getContentType().getContentTypeId()); ITF8.writeUnsignedITF8(getContentId(), outputStream); ITF8.writeUnsignedITF8(getCompressedContentSize(), outputStream); ITF8.writeUnsignedITF8(getUncompressedContentSize(), outputStream); outputStream.write(getCompressedContent()); }
final BlockCompressionMethod compressionMethod = BlockCompressionMethod.byId(inputStream.read()); final BlockContentType contentType = BlockContentType.byId(inputStream.read()); final int contentId = ITF8.readUnsignedITF8(inputStream);
private void doWrite(final OutputStream outputStream) throws IOException { outputStream.write(getCompressionMethod().getMethodId()); outputStream.write(getContentType().getContentTypeId()); ITF8.writeUnsignedITF8(getContentId(), outputStream); ITF8.writeUnsignedITF8(getCompressedContentSize(), outputStream); ITF8.writeUnsignedITF8(getUncompressedContentSize(), outputStream); outputStream.write(getCompressedContent()); }
final BlockCompressionMethod compressionMethod = BlockCompressionMethod.byId(inputStream.read()); final BlockContentType contentType = BlockContentType.byId(inputStream.read()); final int contentId = ITF8.readUnsignedITF8(inputStream);
@Override public String toString() { final byte[] uncompressed = getUncompressedContent(); final byte[] compressed = getCompressedContent(); final String raw = Arrays.toString(Arrays.copyOf(uncompressed, Math.min(5, uncompressed.length))); final String comp = Arrays.toString(Arrays.copyOf(compressed, Math.min(5, compressed.length))); return String.format("compression method=%s, content type=%s, id=%d, raw size=%d, compressed size=%d, raw=%s, comp=%s.", getCompressionMethod().name(), getContentType().name(), getContentId(), getUncompressedContentSize(), getCompressedContentSize(), raw, comp); } }
public static byte[] uncompress(final BlockCompressionMethod method, final byte[] compressedContent) { try { switch (method) { case RAW: return compressedContent; case GZIP: return gunzip(compressedContent); case BZIP2: return unbzip2(compressedContent); case LZMA: return unxz(compressedContent); case RANS: return unrans(compressedContent); default: throw new RuntimeException("Unknown block compression method: " + method.name()); } } catch (final IOException e) { throw new RuntimeException(e); } } }
public static byte[] uncompress(final BlockCompressionMethod method, final byte[] compressedContent) { switch (method) { case RAW: return compressedContent; case GZIP: return gunzip(compressedContent); case BZIP2: return unbzip2(compressedContent); case LZMA: return unxz(compressedContent); case RANS: return unrans(compressedContent); default: throw new RuntimeException("Unknown block compression method: " + method.name()); } } }