Changeset 7867 in josm


Ignore:
Timestamp:
2014-12-21T01:30:50+01:00 (9 years ago)
Author:
Don-vip
Message:

see #10448 - Upgrade Bzip2 library to latest version of Apache Commons Compress. The Bzip2 code inside Apache Ant is no longer maintained. Update also CONTRIBUTION and README files + Javadoc update in Utils.

Location:
trunk
Files:
1 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/.classpath

    r7838 r7867  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<classpath>
    3         <classpathentry kind="src" path="src"/>
     3        <classpathentry excluding="org/apache/commons/compress/compressors/lzma/|org/apache/commons/compress/compressors/xz/|org/apache/commons/compress/compressors/CompressorStreamFactory.java|org/apache/commons/compress/compressors/deflate/|org/apache/commons/compress/compressors/gzip/|org/apache/commons/compress/compressors/lzw/|org/apache/commons/compress/compressors/pack200/|org/apache/commons/compress/compressors/snappy/|org/apache/commons/compress/compressors/z/" kind="src" path="src"/>
    44        <classpathentry kind="src" path="test/unit"/>
    55        <classpathentry kind="src" path="test/functional"/>
  • trunk/CONTRIBUTION

    r7799 r7867  
    3838with Apache license version 2.0.
    3939
    40 The Bzip2 code is from Keiron Liddle (Apache project) and licensed
     40The Bzip2 code is from Apache Commons Compress and licensed
    4141with Apache license version 2.0.
    4242
  • trunk/README

    r7489 r7867  
    5959- CONTRIBUTION              list of major code contributors
    6060- data/                     data files that will be included in the JOSM jar file
    61     - *.gsb                 NTv2 grid files for projection support
     61    - fonts/                font files used for map rendering
     62    - projection/           projection files
     63      - *.gsb               NTv2 grid files for projection support
     64      - epsg                list of projection definitions
    6265    - *.lang                translation data
    6366    - *.xsd                 xml schema files for validation of configuration files
    64     - epsg                  list of projection definitions
    6567    - help-browser.css      CSS file for the help sites (HTML content is downloaded from the website
    6668                            on demand, but displayed inside the programm in a Java web browser component.)
    67     - ignoretags.cfg, tagchecker.cfg
    68                             data files used by the JOSM validator feature
     69    - validator/            data files used by the JOSM validator feature
     70      - *.cfg               files designed for the old tagchecker, still used
     71      - *.mapcss            default validation rules for the new mapcss-based tagchecker
    6972- data_nodist/              data files that are useful for development, but not distributed
    7073    - exif-direction-example.jpg
     
    8891- images_nodist/            images, which are not for distribution, but may be useful later (e.g. high
    8992                            resolution and vector versions)
    90 - josm.jnlp                 Java Web Start launcher file (used on the website)
    91 - lib/                      libraries (directory is empty at the moment)
     93- josm.jnlp                 Java Web Start launcher file (used on the website for the tested version)
     94- josm-latest.jnlp          Java Web Start launcher file (used on the website for the latest version)
    9295- LICENSE                   the JOSM license terms
    93 - macosx/                   files needed to create the MacOS package
     96- linux/                    files useful for Linux distributions, including Appdata files, .desktop
     97                            files, Debian/Ubuntu scripts, man pages, icons, etc.
     98- macosx/                   files needed to create the MacOS X package
    9499- netbeans/                 preconfigured Netbeans project
    95100- optimize-images           short script to decrease size of PNG images
    96101- patches/                  patches for external libraries used in JOSM (see below)
    97102- README                    this file
     103- resources/                resource files that will be included in the JOSM jar file
     104- scripts/                  various scripts used by JOSM developers
    98105- src/                      the source code of the program
    99106- start.html                HTML page to run the applet version of JOSM
     
    108115    - unit/                 unit tests (source code)
    109116- tools/                    libraries and tools that help in the development process
    110     - animal-sniffer-ant-tasks-1.8.jar
     117    - animal-sniffer-ant-tasks-1.11.jar
    111118                            TODO: what is this?
    112119    - appbundler-1.0ea.jar  used to build Mac OS X package for Oracle Java 7
    113120    - findbugs/             libs and config files for findbugs (automatically detects common bugs and potential
    114121                            problems in source code); can be launched as an ant target in build.xml
     122    - groovy-all-2.3.9.jar  used for some unit tests and various scripts
    115123    - jacocoant.jar         used to include coverage data into JUnit test reports
    116124    - javacc.jar            used in the build process to generate some .java files from a javacc source file
    117125                            (src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj)
    118126    - proguard.jar          optimize final binary jar - see build.xml (not used in production so far)
     127    - xmltask.jar           used to edit XML files from Ant for the OSX package
     128- windows/                  files needed to create the Windows installer
    119129
    120130The 'patches' directory
     
    133143Third party libraries
    134144---------------------
    135 There are a couple of third party libraries which are directly included in the source code tree, in particular:
     145There are some third party libraries which are directly included in the source code tree, in particular:
    136146
    137147* jmapviewer: Java component to browse a TMS map
    138148    src/org/openstreetmap/gui (svn external)
    139149    -> http://svn.openstreetmap.org/applications/viewer/jmapviewer/
    140 * Apache Ant's bzip2: Support for bzip2 compression when opening files
    141     src/org/apache/tools/bzip2 (svn external)
    142     -> http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools/bzip2
    143150* Apache commons codec: Better Base64 support
    144151    src/org/apache/commons/codec (svn external)
    145152    -> http://svn.apache.org/repos/asf/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec
     153* Apache commons compress: Support for bzip2 compression when opening files
     154    src/org/apache/commons/compress/compressors (svn external)
     155    -> http://svn.apache.org/repos/asf/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors
    146156* Apache commons validator: Improved validator routines
    147157    src/org/openstreetmap/josm/data/validation/routines
  • trunk/src/org/openstreetmap/josm/io/Compression.java

    r7119 r7867  
    1313import java.util.zip.ZipOutputStream;
    1414
    15 import org.apache.tools.bzip2.CBZip2OutputStream;
     15import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
    1616import org.openstreetmap.josm.tools.Utils;
    1717
     
    9898        switch (this) {
    9999            case BZIP2:
    100                 out.write('B');
    101                 out.write('Z');
    102                 return new CBZip2OutputStream(out);
     100                return new BZip2CompressorOutputStream(out);
    103101            case GZIP:
    104102                return new GZIPOutputStream(out);
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7864 r7867  
    5151import java.util.zip.ZipInputStream;
    5252
    53 import org.apache.tools.bzip2.CBZip2InputStream;
     53import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
    5454import org.openstreetmap.josm.Main;
    5555import org.openstreetmap.josm.data.Version;
     
    159159
    160160    /**
    161      * Get minimum of 3 values
     161     * Returns the minimum of three values.
     162     * @param   a   an argument.
     163     * @param   b   another argument.
     164     * @param   c   another argument.
     165     * @return  the smaller of {@code a}, {@code b} and {@code c}.
    162166     */
    163167    public static int min(int a, int b, int c) {
     
    173177    }
    174178
     179    /**
     180     * Returns the greater of four {@code int} values. That is, the
     181     * result is the argument closer to the value of
     182     * {@link Integer#MAX_VALUE}. If the arguments have the same value,
     183     * the result is that same value.
     184     *
     185     * @param   a   an argument.
     186     * @param   b   another argument.
     187     * @param   c   another argument.
     188     * @param   d   another argument.
     189     * @return  the larger of {@code a}, {@code b}, {@code c} and {@code d}.
     190     */
    175191    public static int max(int a, int b, int c, int d) {
    176192        return Math.max(Math.max(a, b), Math.max(c, d));
    177193    }
    178194
     195    /**
     196     * Ensures a logical condition is met. Otherwise throws an assertion error.
     197     * @param condition the condition to be met
     198     * @param message Formatted error message to raise if condition is not met
     199     * @param data Message parameters, optional
     200     * @throws AssertionError if the condition is not met
     201     */
    179202    public static void ensure(boolean condition, String message, Object...data) {
    180203        if (!condition)
     
    209232        if (values == null)
    210233            return null;
    211         if (values.isEmpty())
    212             return "";
    213234        StringBuilder s = null;
    214235        for (Object a : values) {
     
    222243            }
    223244        }
    224         return s.toString();
     245        return s != null ? s.toString() : "";
    225246    }
    226247
     
    361382    }
    362383
     384    /**
     385     * Copy data from source stream to output stream.
     386     * @param source source stream
     387     * @param destination target stream
     388     * @return number of bytes copied
     389     * @throws IOException if any I/O error occurs
     390     */
    363391    public static int copyStream(InputStream source, OutputStream destination) throws IOException {
    364392        int count = 0;
     
    702730     * Opens a connection to the given URL, sets the User-Agent property to JOSM's one, and decompresses stream if necessary.
    703731     * @param url The url to open
    704      * @param decompress whether to wrap steam in a {@link GZIPInputStream} or {@link CBZip2InputStream}
     732     * @param decompress whether to wrap steam in a {@link GZIPInputStream} or {@link BZip2CompressorInputStream}
    705733     *                   if the {@code Content-Type} header is set accordingly.
    706734     * @return An stream for the given URL
     
    729757     * @return a Bzip2 input stream wrapping given input stream, or {@code null} if {@code in} is {@code null}
    730758     * @throws IOException if the given input stream does not contain valid BZ2 header
    731      * @since 7119
    732      */
    733     public static CBZip2InputStream getBZip2InputStream(InputStream in) throws IOException {
     759     * @since 7867
     760     */
     761    public static BZip2CompressorInputStream getBZip2InputStream(InputStream in) throws IOException {
    734762        if (in == null) {
    735763            return null;
    736764        }
    737765        BufferedInputStream bis = new BufferedInputStream(in);
    738         int b = bis.read();
    739         if (b != 'B')
    740             throw new IOException(tr("Invalid bz2 file."));
    741         b = bis.read();
    742         if (b != 'Z')
    743             throw new IOException(tr("Invalid bz2 file."));
    744         return new CBZip2InputStream(bis, /* see #9537 */ true);
     766        return new BZip2CompressorInputStream(bis, /* see #9537 */ true);
    745767    }
    746768
     
    808830     * Opens a connection to the given URL and sets the User-Agent property to JOSM's one.
    809831     * @param url The url to open
    810      * @param decompress whether to wrap steam in a {@link GZIPInputStream} or {@link CBZip2InputStream}
     832     * @param decompress whether to wrap steam in a {@link GZIPInputStream} or {@link BZip2CompressorInputStream}
    811833     *                   if the {@code Content-Type} header is set accordingly.
    812834     * @return An buffered stream reader for the given URL (using UTF-8)
     
    929951     * @since 6354
    930952     */
    931     public static String getDurationString(long elapsedTime) throws IllegalArgumentException {
     953    public static String getDurationString(long elapsedTime) {
    932954        if (elapsedTime < 0) {
    933955            throw new IllegalArgumentException("elapsedTime must be >= 0");
     
    10331055        if (result != null) {
    10341056            Throwable cause = result.getCause();
    1035             while (cause != null && cause != result) {
     1057            while (cause != null && !cause.equals(result)) {
    10361058                result = cause;
    10371059                cause = result.getCause();
     
    10561078    /**
    10571079     * If the string {@code s} is longer than {@code maxLength}, the string is cut and "..." is appended.
     1080     * @param s String to shorten
     1081     * @param maxLength maximum number of characters to keep (not including the "...")
     1082     * @return the shortened string
    10581083     */
    10591084    public static String shortenString(String s, int maxLength) {
Note: See TracChangeset for help on using the changeset viewer.