Ignore:
Timestamp:
2015-12-26T23:41:57+01:00 (5 years ago)
Author:
simon04
Message:

see #12231 - Deprecate Utils.open* functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r9072 r9170  
    765765     * @throws java.io.IOException if an I/O exception occurs.
    766766     * @since 5587
    767      */
     767     * @deprecated Use {@link HttpClient} instead
     768     */
     769    @Deprecated
    768770    public static HttpURLConnection openHttpConnection(URL httpURL) throws IOException {
    769771        if (httpURL == null || !HTTP_PREFFIX_PATTERN.matcher(httpURL.getProtocol()).matches()) {
     
    785787     * @throws java.io.IOException if an I/O exception occurs.
    786788     * @since 5867
    787      */
     789     * @deprecated Use {@link HttpClient} instead
     790     */
     791    @Deprecated
    788792    public static InputStream openURL(URL url) throws IOException {
    789         return openURLAndDecompress(url, false);
     793        return HttpClient.create(url).connect().getContent();
    790794    }
    791795
     
    798802     * @throws IOException if an I/O exception occurs.
    799803     * @since 6421
    800      */
     804     * @deprecated Use {@link HttpClient} instead
     805     */
     806    @Deprecated
    801807    public static InputStream openURLAndDecompress(final URL url, final boolean decompress) throws IOException {
    802         final URLConnection connection = setupURLConnection(url.openConnection());
    803         final InputStream in = connection.getInputStream();
    804         if (decompress) {
    805             switch (connection.getHeaderField("Content-Type")) {
    806             case "application/zip":
    807                 return getZipInputStream(in);
    808             case "application/x-gzip":
    809                 return getGZipInputStream(in);
    810             case "application/x-bzip2":
    811                 return getBZip2InputStream(in);
    812             }
    813         }
    814         return in;
     808        return HttpClient.create(url).connect().uncompress(decompress).getContent();
    815809    }
    816810
     
    868862     * @return {@code connection}, with updated properties
    869863     * @since 5887
    870      */
     864     * @deprecated Use {@link HttpClient} instead
     865     */
     866    @Deprecated
    871867    public static URLConnection setupURLConnection(URLConnection connection) {
    872868        if (connection != null) {
     
    884880     * @throws java.io.IOException if an I/O exception occurs.
    885881     * @since 5868
    886      */
     882     * @deprecated Use {@link HttpClient} instead
     883     */
     884    @Deprecated
    887885    public static BufferedReader openURLReader(URL url) throws IOException {
    888         return openURLReaderAndDecompress(url, false);
     886        return HttpClient.create(url).connect().getContentReader();
    889887    }
    890888
     
    897895     * @throws IOException if an I/O exception occurs.
    898896     * @since 6421
    899      */
     897     * @deprecated Use {@link HttpClient} instead
     898     */
     899    @Deprecated
    900900    public static BufferedReader openURLReaderAndDecompress(final URL url, final boolean decompress) throws IOException {
    901         return new BufferedReader(new InputStreamReader(openURLAndDecompress(url, decompress), StandardCharsets.UTF_8));
     901        return HttpClient.create(url).connect().uncompress(decompress).getContentReader();
    902902    }
    903903
     
    909909     * @throws java.io.IOException if an I/O exception occurs.
    910910     * @since 5587
    911      */
     911     * @deprecated Use {@link HttpClient} instead
     912     */
     913    @Deprecated
    912914    public static HttpURLConnection openHttpConnection(URL httpURL, boolean keepAlive) throws IOException {
    913915        HttpURLConnection connection = openHttpConnection(httpURL);
     
    935937     * @throws IOException if an I/O exception occurs
    936938     * @since 8650
    937      */
     939     * @deprecated Use {@link HttpClient} instead
     940     */
     941    @Deprecated
    938942    public static HttpURLConnection openHttpConnection(URL httpURL, boolean keepAlive, boolean followRedirects) throws IOException {
    939943        HttpURLConnection connection = openHttpConnection(httpURL, keepAlive);
Note: See TracChangeset for help on using the changeset viewer.