@Test public void testDivineDeflateParameters_AllValidSettings() throws IOException { for (boolean nowrap : new boolean[] {true, false}) { for (int strategy : new int[] {0, 1, 2}) { for (int level : new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9}) { JreDeflateParameters trueParameters = JreDeflateParameters.of(level, strategy, nowrap); final byte[] buffer = deflate(trueParameters); ByteArrayInputStreamFactory factory = new ByteArrayInputStreamFactory(buffer, true, false); JreDeflateParameters divinedParameters = diviner.divineDeflateParameters(factory); Assert.assertNotNull(divinedParameters); if (strategy == 1 && level <= 3) { Assert.assertEquals(JreDeflateParameters.of(level, 0, nowrap), divinedParameters); } else if (strategy == 2) { Assert.assertEquals(nowrap, divinedParameters.nowrap); Assert.assertEquals(strategy, divinedParameters.strategy); } else { Assert.assertEquals(trueParameters, divinedParameters); } } } } }
public List<DivinationResult> divineDeflateParameters(File archiveFile) throws IOException { List<DivinationResult> results = new ArrayList<DivinationResult>(); for (MinimalZipEntry minimalZipEntry : MinimalZipArchive.listEntries(archiveFile)) { JreDeflateParameters divinedParameters = null; if (minimalZipEntry.isDeflateCompressed()) { RandomAccessFileInputStreamFactory rafisFactory = new RandomAccessFileInputStreamFactory( archiveFile, minimalZipEntry.getFileOffsetOfCompressedData(), minimalZipEntry.getCompressedSize()); divinedParameters = divineDeflateParameters(rafisFactory); } results.add(new DivinationResult(minimalZipEntry, divinedParameters)); } return results; }
DefaultDeflateCompressionDiviner { public List<DivinationResult> divineDeflateParameters(File archiveFile) throws IOException { List<DivinationResult> results = new ArrayList<DivinationResult>(); for (MinimalZipEntry minimalZipEntry : MinimalZipArchive.listEntries(archiveFile)) { JreDeflateParameters divinedParameters = null; if (minimalZipEntry.isDeflateCompressed()) { RandomAccessFileInputStreamFactory rafisFactory = new RandomAccessFileInputStreamFactory( archiveFile, minimalZipEntry.getFileOffsetOfCompressedData(), minimalZipEntry.getCompressedSize()); divinedParameters = divineDeflateParameters(rafisFactory); } results.add(new DivinationResult(minimalZipEntry, divinedParameters)); } return results; } }
DefaultDeflateCompressionDiviner { public List<DivinationResult> divineDeflateParameters(File archiveFile) throws IOException { List<DivinationResult> results = new ArrayList<DivinationResult>(); for (MinimalZipEntry minimalZipEntry : MinimalZipArchive.listEntries(archiveFile)) { JreDeflateParameters divinedParameters = null; if (minimalZipEntry.isDeflateCompressed()) { RandomAccessFileInputStreamFactory rafisFactory = new RandomAccessFileInputStreamFactory( archiveFile, minimalZipEntry.getFileOffsetOfCompressedData(), minimalZipEntry.getCompressedSize()); divinedParameters = divineDeflateParameters(rafisFactory); } results.add(new DivinationResult(minimalZipEntry, divinedParameters)); } return results; }  }
DefaultDeflateCompressionDiviner { public List<DivinationResult> divineDeflateParameters(File archiveFile) throws IOException { List<DivinationResult> results = new ArrayList<DivinationResult>(); for (MinimalZipEntry minimalZipEntry : MinimalZipArchive.listEntries(archiveFile)) { JreDeflateParameters divinedParameters = null; if (minimalZipEntry.isDeflateCompressed()) { RandomAccessFileInputStreamFactory rafisFactory = new RandomAccessFileInputStreamFactory( archiveFile, minimalZipEntry.getFileOffsetOfCompressedData(), minimalZipEntry.getCompressedSize()); divinedParameters = divineDeflateParameters(rafisFactory); } results.add(new DivinationResult(minimalZipEntry, divinedParameters)); } return results; }  List<DivinationResult> divineDeflateParameters(File archiveFile); JreDeflateParameters divineDeflateParameters(
      MultiViewInputStreamFactory<?> compressedDataInputStreamFactory); }
DefaultDeflateCompressionDiviner { public List<DivinationResult> divineDeflateParameters(File archiveFile) throws IOException { List<DivinationResult> results = new ArrayList<DivinationResult>(); for (MinimalZipEntry minimalZipEntry : MinimalZipArchive.listEntries(archiveFile)) { JreDeflateParameters divinedParameters = null; if (minimalZipEntry.isDeflateCompressed()) { RandomAccessFileInputStreamFactory rafisFactory = new RandomAccessFileInputStreamFactory( archiveFile, minimalZipEntry.getFileOffsetOfCompressedData(), minimalZipEntry.getCompressedSize()); divinedParameters = divineDeflateParameters(rafisFactory); } results.add(new DivinationResult(minimalZipEntry, divinedParameters)); } return results; }  List<DivinationResult> divineDeflateParameters(File archiveFile); JreDeflateParameters divineDeflateParameters(
      MultiViewInputStreamFactory<?> compressedDataInputStreamFactory);  }