@Test public void testCompressionMetadata() throws Exception { LZMAOutputStream lzma = runCompressMode(new LzmaProfile(16 * 1024, 128, Encoder.EMatchFinderTypeBT2)); Map<String, String> m = lzma.getStreamMetadata(); assertEquals("Uncompressed digest incorrect", "027e997e6b1dfc97b93eb28dc9a6804096d85873", m.get(TransformConstants.META_COMPRESSION_UNCOMP_SHA1)); assertEquals("Compression ratio incorrect", "93.9%", m.get(TransformConstants.META_COMPRESSION_COMP_RATIO)); assertEquals("Uncompressed size incorrect", 2516125, Long.parseLong(m .get(TransformConstants.META_COMPRESSION_UNCOMP_SIZE))); assertEquals("Compressed size incorrect", 154656, Long.parseLong(m .get(TransformConstants.META_COMPRESSION_COMP_SIZE))); }
@Override public Map<String, String> getStreamMetadata() { if(!closed) { throw new IllegalStateException("Stream must be closed before getting metadata"); } Map<String,String> metadata = new HashMap<String, String>(); long compSize = compressedOutput.getByteCount(); long uncompSize = uncompressedSize.getByteCount(); String compRatioString = String.format("%.1f%%", 100.0 - (compSize*100.0/uncompSize)); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SIZE, ""+uncompSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_SIZE, ""+compSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_RATIO, ""+compRatioString); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SHA1, KeyUtils.toHexPadded(uncompressedDigest)); return metadata; }
LZMAOutputStream extends OutputStream implements CompressionStream, Runnable { @Override public Map<String, String> getStreamMetadata() { if(!closed) { throw new IllegalStateException("Stream must be closed before getting metadata"); } Map<String,String> metadata = new HashMap<String, String>(); long compSize = compressedOutput.getByteCount(); long uncompSize = uncompressedSize.getByteCount(); String compRatioString = String.format("%.1f%%", 100.0 - (compSize*100.0/uncompSize)); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SIZE, ""+uncompSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_SIZE, ""+compSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_RATIO, ""+compRatioString); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SHA1, KeyUtils.toHexPadded(uncompressedDigest)); return metadata; } }
LZMAOutputStream extends OutputStream implements CompressionStream, Runnable { @Override public Map<String, String> getStreamMetadata() { if(!closed) { throw new IllegalStateException("Stream must be closed before getting metadata"); } Map<String,String> metadata = new HashMap<String, String>(); long compSize = compressedOutput.getByteCount(); long uncompSize = uncompressedSize.getByteCount(); String compRatioString = String.format("%.1f%%", 100.0 - (compSize*100.0/uncompSize)); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SIZE, ""+uncompSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_SIZE, ""+compSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_RATIO, ""+compRatioString); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SHA1, KeyUtils.toHexPadded(uncompressedDigest)); return metadata; } LZMAOutputStream(OutputStream out, LzmaProfile compressionProfile);  LZMAOutputStream(OutputStream out, int compressionLevel); }
LZMAOutputStream extends OutputStream implements CompressionStream, Runnable { @Override public Map<String, String> getStreamMetadata() { if(!closed) { throw new IllegalStateException("Stream must be closed before getting metadata"); } Map<String,String> metadata = new HashMap<String, String>(); long compSize = compressedOutput.getByteCount(); long uncompSize = uncompressedSize.getByteCount(); String compRatioString = String.format("%.1f%%", 100.0 - (compSize*100.0/uncompSize)); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SIZE, ""+uncompSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_SIZE, ""+compSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_RATIO, ""+compRatioString); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SHA1, KeyUtils.toHexPadded(uncompressedDigest)); return metadata; } LZMAOutputStream(OutputStream out, LzmaProfile compressionProfile);  LZMAOutputStream(OutputStream out, int compressionLevel); @Override Map<String, String> getStreamMetadata(); @Override void write(int b); @Override void close(); @Override void flush(); @Override void write(byte[] b, int off, int len); @Override void write(byte[] b); @Override void run(); }
LZMAOutputStream extends OutputStream implements CompressionStream, Runnable { @Override public Map<String, String> getStreamMetadata() { if(!closed) { throw new IllegalStateException("Stream must be closed before getting metadata"); } Map<String,String> metadata = new HashMap<String, String>(); long compSize = compressedOutput.getByteCount(); long uncompSize = uncompressedSize.getByteCount(); String compRatioString = String.format("%.1f%%", 100.0 - (compSize*100.0/uncompSize)); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SIZE, ""+uncompSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_SIZE, ""+compSize); metadata.put(TransformConstants.META_COMPRESSION_COMP_RATIO, ""+compRatioString); metadata.put(TransformConstants.META_COMPRESSION_UNCOMP_SHA1, KeyUtils.toHexPadded(uncompressedDigest)); return metadata; } LZMAOutputStream(OutputStream out, LzmaProfile compressionProfile);  LZMAOutputStream(OutputStream out, int compressionLevel); @Override Map<String, String> getStreamMetadata(); @Override void write(int b); @Override void close(); @Override void flush(); @Override void write(byte[] b, int off, int len); @Override void write(byte[] b); @Override void run();  }