| 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | /** |
| 21 | * <p> |
| 22 | * Provides stream classes for compressing and decompressing streams using the Pack200 algorithm used to compress Java archives. |
| 23 | * </p> |
| 24 | * <p> |
| 25 | * The streams of this package only work on JAR archives, i.e. a {@link org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream |
| 26 | * Pack200CompressorOutputStream} expects to be wrapped around a stream that a valid JAR archive will be written to and a |
| 27 | * {@link org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream Pack200CompressorInputStream} provides a stream to read from a JAR |
| 28 | * archive. |
| 29 | * </p> |
| 30 | * <p> |
| 31 | * JAR archives compressed with Pack200 will in general be different from the original archive when decompressed again. For details see the |
| 32 | * <a href="https://download.oracle.com/javase/1.5.0/docs/api/java/util/jar/Pack200.html">API documentation of Pack200</a>. |
| 33 | * </p> |
| 34 | * <p> |
| 35 | * The streams of this package work on non-deflated streams, i.e. archives like those created with the {@code --no-gzip} option of the JDK's |
| 36 | * {@code pack200} command line tool. If you want to work on deflated streams you must use an additional stream layer - for example by using Apache Commons |
| 37 | * Compress' gzip package. |
| 38 | * </p> |
| 39 | * <p> |
| 40 | * The Pack200 API provided by the Java class library doesn't lend itself to real stream processing. {@code Pack200CompressorInputStream} will uncompress |
| 41 | * its input immediately and then provide an {@code InputStream} to a cached result. Likewise {@code Pack200CompressorOutputStream} will not write |
| 42 | * anything to the given OutputStream until {@code finish} or {@code close} is called - at which point the cached output written so far gets |
| 43 | * compressed. |
| 44 | * </p> |
| 45 | * <p> |
| 46 | * Two different caching modes are available - "in memory", which is the default, and "temporary file". By default data is cached in memory but you should |
| 47 | * switch to the temporary file option if your archives are really big. |
| 48 | * </p> |
| 49 | * <p> |
| 50 | * Given there always is an intermediate result the {@code getBytesRead} and {@code getCount} methods of {@code Pack200CompressorInputStream} are |
| 51 | * meaningless (read from the real stream or from the intermediate result?) and always return 0. |
| 52 | * </p> |
| 53 | * <p> |
| 54 | * During development of the initial version several attempts have been made to use a real streaming API based for example on |
| 55 | * {@code Piped(In|Out)putStream} or explicit stream pumping like Commons Exec's {@code InputStreamPumper} but they have all failed because they rely |
| 56 | * on the output end to be consumed completely or else the {@code (un)pack} will block forever. Especially for {@code Pack200InputStream} it is very |
| 57 | * likely that it will be wrapped in a {@code ZipArchiveInputStream} which will never read the archive completely as it is not interested in the ZIP |
| 58 | * central directory data at the end of the JAR archive. |
| 59 | * </p> |
| 60 | */ |
| 61 | package org.apache.commons.compress.compressors.pack200; |