[guava-libraries] 03/05: Added a patch reintroducing the methods removed from the Files, ByteStreams and CharStreams classes

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Fri May 22 10:29:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository guava-libraries.

commit c5c0ef5a2decd616c2f00a1694b19160d2311a10
Author: Emmanuel Bourg <ebourg at apache.org>
Date:   Fri May 22 09:43:19 2015 +0200

    Added a patch reintroducing the methods removed from the Files, ByteStreams and CharStreams classes
---
 debian/changelog                                   |   3 +
 .../patches/06-preserve-pre-guava18-methods.patch  | 505 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 3 files changed, 509 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 11ea1c6..9a6f118 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,9 @@ guava-libraries (18.0-1) UNRELEASED; urgency=medium
 
   * New upstream release
     - Refreshed the patches
+    - Added a patch reintroducing the deprecated methods removed
+      from the Files, ByteStreams and CharStreams classes still used
+      by other packages (gradle andclosure-compiler)
   * Modified the short description of libguava-java (Closes: #729355)
   * Standards-Version updated to 3.9.6 (no changes)
 
diff --git a/debian/patches/06-preserve-pre-guava18-methods.patch b/debian/patches/06-preserve-pre-guava18-methods.patch
new file mode 100644
index 0000000..f0c2514
--- /dev/null
+++ b/debian/patches/06-preserve-pre-guava18-methods.patch
@@ -0,0 +1,505 @@
+Description: Preserves some of the methods from the Files, ByteStreams
+ and CharStreams classes that were removed in Guava 18. This patch can be
+ removed once closure-compiler and gradle switch to Guava 18 or higher.
+Author: Emmanuel Bourg <ebourg at pache.org>
+Forwarded: not-needed
+--- a/guava/src/com/google/common/io/Files.java
++++ b/guava/src/com/google/common/io/Files.java
+@@ -231,6 +231,54 @@
+     return asByteSink(file, modes).asCharSink(charset);
+   }
+ 
++  /**
++   * Returns a factory that will supply instances of {@link FileInputStream}
++   * that read from a file.
++   *
++   * @param file the file to read from
++   * @return the factory
++   * @deprecated Use {@link #asByteSource(File)}. This method is scheduled for
++   *     removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<FileInputStream> newInputStreamSupplier(
++      final File file) {
++    return ByteStreams.asInputSupplier(asByteSource(file));
++  }
++
++  /**
++   * Returns a factory that will supply instances of {@link FileOutputStream}
++   * that write to a file.
++   *
++   * @param file the file to write to
++   * @return the factory
++   * @deprecated Use {@link #asByteSink(File)}. This method is scheduled for
++   *     removal in Guava 18.0.
++   */
++  @Deprecated
++  public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
++      File file) {
++    return newOutputStreamSupplier(file, false);
++  }
++
++  /**
++   * Returns a factory that will supply instances of {@link FileOutputStream}
++   * that write to or append to a file.
++   *
++   * @param file the file to write to
++   * @param append if true, the encoded characters will be appended to the file;
++   *     otherwise the file is overwritten
++   * @return the factory
++   * @deprecated Use {@link #asByteSink(File, FileWriteMode...)}, passing
++   *     {@link FileWriteMode#APPEND} for append. This method is scheduled for
++   *     removal in Guava 18.0.
++   */
++  @Deprecated
++  public static OutputSupplier<FileOutputStream> newOutputStreamSupplier(
++      final File file, final boolean append) {
++    return ByteStreams.asOutputSupplier(asByteSink(file, modes(append)));
++  }
++
+   private static FileWriteMode[] modes(boolean append) {
+     return append
+         ? new FileWriteMode[]{ FileWriteMode.APPEND }
+@@ -238,6 +286,60 @@
+   }
+ 
+   /**
++   * Returns a factory that will supply instances of
++   * {@link InputStreamReader} that read a file using the given character set.
++   *
++   * @param file the file to read from
++   * @param charset the charset used to decode the input stream; see {@link
++   *     Charsets} for helpful predefined constants
++   * @return the factory
++   * @deprecated Use {@link #asCharSource(File, Charset)}. This method is
++   *     scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<InputStreamReader> newReaderSupplier(File file,
++      Charset charset) {
++    return CharStreams.asInputSupplier(asCharSource(file, charset));
++  }
++
++  /**
++   * Returns a factory that will supply instances of {@link OutputStreamWriter}
++   * that write to a file using the given character set.
++   *
++   * @param file the file to write to
++   * @param charset the charset used to encode the output stream; see {@link
++   *     Charsets} for helpful predefined constants
++   * @return the factory
++   * @deprecated Use {@link #asCharSink(File, Charset)}. This method is
++   *     scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static OutputSupplier<OutputStreamWriter> newWriterSupplier(File file,
++      Charset charset) {
++    return newWriterSupplier(file, charset, false);
++  }
++
++  /**
++   * Returns a factory that will supply instances of {@link OutputStreamWriter}
++   * that write to or append to a file using the given character set.
++   *
++   * @param file the file to write to
++   * @param charset the charset used to encode the output stream; see {@link
++   *     Charsets} for helpful predefined constants
++   * @param append if true, the encoded characters will be appended to the file;
++   *     otherwise the file is overwritten
++   * @return the factory
++   * @deprecated Use {@link #asCharSink(File, Charset, FileWriteMode...)},
++   *     passing {@link FileWriteMode#APPEND} for append. This method is
++   *     scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static OutputSupplier<OutputStreamWriter> newWriterSupplier(File file,
++      Charset charset, boolean append) {
++    return CharStreams.asOutputSupplier(asCharSink(file, charset, modes(append)));
++  }
++
++  /**
+    * Reads all bytes from a file into a byte array.
+    *
+    * @param file the file to read from
+--- a/guava/src/com/google/common/io/ByteStreams.java
++++ b/guava/src/com/google/common/io/ByteStreams.java
+@@ -21,6 +21,8 @@
+ import static com.google.common.base.Preconditions.checkPositionIndex;
+ 
+ import com.google.common.annotations.Beta;
++import com.google.common.base.Function;
++import com.google.common.collect.Iterables;
+ 
+ import java.io.ByteArrayInputStream;
+ import java.io.ByteArrayOutputStream;
+@@ -52,6 +54,38 @@
+   private ByteStreams() {}
+ 
+   /**
++   * Returns a factory that will supply instances of
++   * {@link ByteArrayInputStream} that read from the given byte array.
++   *
++   * @param b the input buffer
++   * @return the factory
++   * @deprecated Use {@link ByteSource#wrap(byte[])} instead. This method is
++   *     scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<ByteArrayInputStream> newInputStreamSupplier(
++      byte[] b) {
++    return asInputSupplier(ByteSource.wrap(b));
++  }
++
++  /**
++   * Returns a factory that will supply instances of
++   * {@link ByteArrayInputStream} that read from the given byte array.
++   *
++   * @param b the input buffer
++   * @param off the offset in the buffer of the first byte to read
++   * @param len the maximum number of bytes to read from the buffer
++   * @return the factory
++   * @deprecated Use {@code ByteSource.wrap(b).slice(off, len)} instead. This
++   *     method is scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<ByteArrayInputStream> newInputStreamSupplier(
++      final byte[] b, final int off, final int len) {
++    return asInputSupplier(ByteSource.wrap(b).slice(off, len));
++  }
++
++  /**
+    * Copies all bytes from the input stream to the output stream.
+    * Does not close or flush either stream.
+    *
+@@ -738,4 +772,128 @@
+     }
+     return total;
+   }
++
++  /**
++   * Returns an {@link InputSupplier} that returns input streams from the
++   * an underlying supplier, where each stream starts at the given
++   * offset and is limited to the specified number of bytes.
++   *
++   * @param supplier the supplier from which to get the raw streams
++   * @param offset the offset in bytes into the underlying stream where
++   *     the returned streams will start
++   * @param length the maximum length of the returned streams
++   * @throws IllegalArgumentException if offset or length are negative
++   * @deprecated Use {@link ByteSource#slice(int, int)} instead. This method is
++   *     scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<InputStream> slice(
++      final InputSupplier<? extends InputStream> supplier,
++      final long offset,
++      final long length) {
++    return asInputSupplier(asByteSource(supplier).slice(offset, length));
++  }
++
++  /**
++   * Joins multiple {@link InputStream} suppliers into a single supplier.
++   * Streams returned from the supplier will contain the concatenated data from
++   * the streams of the underlying suppliers.
++   *
++   * <p>Only one underlying input stream will be open at a time. Closing the
++   * joined stream will close the open underlying stream.
++   *
++   * <p>Reading from the joined stream will throw a {@link NullPointerException}
++   * if any of the suppliers are null or return null.
++   *
++   * @param suppliers the suppliers to concatenate
++   * @return a supplier that will return a stream containing the concatenated
++   *     stream data
++   * @deprecated Use {@link ByteSource#concat(Iterable)} instead. This method
++   *     is scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<InputStream> join(
++      final Iterable<? extends InputSupplier<? extends InputStream>> suppliers) {
++    checkNotNull(suppliers);
++    Iterable<ByteSource> sources = Iterables.transform(suppliers,
++        new Function<InputSupplier<? extends InputStream>, ByteSource>() {
++          @Override
++          public ByteSource apply(InputSupplier<? extends InputStream> input) {
++            return asByteSource(input);
++          }
++        });
++    return asInputSupplier(ByteSource.concat(sources));
++  }
++
++  /**
++   * Returns a view of the given {@code InputStream} supplier as a
++   * {@code ByteSource}.
++   *
++   * <p>This method is a temporary method provided for easing migration from
++   * suppliers to sources and sinks.
++   *
++   * @since 15.0
++   * @deprecated Convert all {@code InputSupplier<? extends InputStream>}
++   *     implementations to extend {@link ByteSource} or provide a method for
++   *     viewing the object as a {@code ByteSource}. This method is scheduled
++   *     for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static ByteSource asByteSource(
++      final InputSupplier<? extends InputStream> supplier) {
++    checkNotNull(supplier);
++    return new ByteSource() {
++      @Override
++      public InputStream openStream() throws IOException {
++        return supplier.getInput();
++      }
++
++      @Override
++      public String toString() {
++        return "ByteStreams.asByteSource(" + supplier + ")";
++      }
++    };
++  }
++
++  /**
++   * Returns a view of the given {@code OutputStream} supplier as a
++   * {@code ByteSink}.
++   *
++   * <p>This method is a temporary method provided for easing migration from
++   * suppliers to sources and sinks.
++   *
++   * @since 15.0
++   * @deprecated Convert all {@code OutputSupplier<? extends OutputStream>}
++   *     implementations to extend {@link ByteSink} or provide a method for
++   *     viewing the object as a {@code ByteSink}. This method is scheduled
++   *     for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static ByteSink asByteSink(
++      final OutputSupplier<? extends OutputStream> supplier) {
++    checkNotNull(supplier);
++    return new ByteSink() {
++      @Override
++      public OutputStream openStream() throws IOException {
++        return supplier.getOutput();
++      }
++
++      @Override
++      public String toString() {
++        return "ByteStreams.asByteSink(" + supplier + ")";
++      }
++    };
++  }
++
++  @SuppressWarnings("unchecked") // used internally where known to be safe
++  static <S extends InputStream> InputSupplier<S> asInputSupplier(
++      final ByteSource source) {
++    return (InputSupplier) checkNotNull(source);
++  }
++
++  @SuppressWarnings("unchecked") // used internally where known to be safe
++  static <S extends OutputStream> OutputSupplier<S> asOutputSupplier(
++      final ByteSink sink) {
++    return (OutputSupplier) checkNotNull(sink);
++  }
+ }
+--- a/guava/src/com/google/common/io/CharStreams.java
++++ b/guava/src/com/google/common/io/CharStreams.java
+@@ -24,9 +24,15 @@
+ import java.io.Closeable;
+ import java.io.EOFException;
+ import java.io.IOException;
++import java.io.InputStream;
++import java.io.InputStreamReader;
++import java.io.OutputStream;
++import java.io.OutputStreamWriter;
+ import java.io.Reader;
++import java.io.StringReader;
+ import java.io.Writer;
+ import java.nio.CharBuffer;
++import java.nio.charset.Charset;
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+@@ -52,6 +58,57 @@
+   private CharStreams() {}
+ 
+   /**
++   * Returns a factory that will supply instances of {@link StringReader} that
++   * read a string value.
++   *
++   * @param value the string to read
++   * @return the factory
++   * @deprecated Use {@link CharSource#wrap(CharSequence)} instead. This method
++   *     is scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<StringReader> newReaderSupplier(
++      final String value) {
++    return asInputSupplier(CharSource.wrap(value));
++  }
++
++  /**
++   * Returns a factory that will supply instances of {@link InputStreamReader},
++   * using the given {@link InputStream} factory and character set.
++   *
++   * @param in the factory that will be used to open input streams
++   * @param charset the charset used to decode the input stream; see {@link
++   *     Charsets} for helpful predefined constants
++   * @return the factory
++   * @deprecated Use {@link ByteSource#asCharSource(Charset)} instead. This
++   *     method is scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static InputSupplier<InputStreamReader> newReaderSupplier(
++      final InputSupplier<? extends InputStream> in, final Charset charset) {
++    return asInputSupplier(
++        ByteStreams.asByteSource(in).asCharSource(charset));
++  }
++
++  /**
++   * Returns a factory that will supply instances of {@link OutputStreamWriter},
++   * using the given {@link OutputStream} factory and character set.
++   *
++   * @param out the factory that will be used to open output streams
++   * @param charset the charset used to encode the output stream; see {@link
++   *     Charsets} for helpful predefined constants
++   * @return the factory
++   * @deprecated Use {@link ByteSink#asCharSink(Charset)} instead. This method
++   *     is scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static OutputSupplier<OutputStreamWriter> newWriterSupplier(
++      final OutputSupplier<? extends OutputStream> out, final Charset charset) {
++    return asOutputSupplier(
++        ByteStreams.asByteSink(out).asCharSink(charset));
++  }
++
++  /**
+    * Copies all characters between the {@link Readable} and {@link Appendable}
+    * objects. Does not close or flush either object.
+    *
+@@ -101,6 +158,49 @@
+   }
+ 
+   /**
++   * Reads the first line from a {@link Readable} & {@link Closeable} object
++   * supplied by a factory. The line does not include line-termination
++   * characters, but does include other leading and trailing whitespace.
++   *
++   * @param supplier the factory to read from
++   * @return the first line, or null if the reader is empty
++   * @throws IOException if an I/O error occurs
++   * @deprecated Use {@link CharSource#readFirstLine()} instead. This method is
++   *     scheduled for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static <R extends Readable & Closeable> String readFirstLine(
++      InputSupplier<R> supplier) throws IOException {
++    return asCharSource(supplier).readFirstLine();
++  }
++
++  /**
++   * Reads all of the lines from a {@link Readable} & {@link Closeable} object
++   * supplied by a factory. The lines do not include line-termination
++   * characters, but do include other leading and trailing whitespace.
++   *
++   * @param supplier the factory to read from
++   * @return a mutable {@link List} containing all the lines
++   * @throws IOException if an I/O error occurs
++   * @deprecated Use {@link CharSource#readLines()} instead, but note that it
++   *     returns an {@code ImmutableList}. This method is scheduled for removal
++   *     in Guava 18.0.
++   */
++  @Deprecated
++  public static <R extends Readable & Closeable> List<String> readLines(
++      InputSupplier<R> supplier) throws IOException {
++    Closer closer = Closer.create();
++    try {
++      R r = closer.register(supplier.getInput());
++      return readLines(r);
++    } catch (Throwable e) {
++      throw closer.rethrow(e);
++    } finally {
++      closer.close();
++    }
++  }
++
++  /**
+    * Reads all of the lines from a {@link Readable} object. The lines do
+    * not include line-termination characters, but do include other
+    * leading and trailing whitespace.
+@@ -286,4 +386,76 @@
+       }
+     };
+   }
++
++  /**
++   * Returns a view of the given {@code Readable} supplier as a
++   * {@code CharSource}.
++   *
++   * <p>This method is a temporary method provided for easing migration from
++   * suppliers to sources and sinks.
++   *
++   * @since 15.0
++   * @deprecated Convert all {@code InputSupplier<? extends Readable>}
++   *     implementations to extend {@link CharSource} or provide a method for
++   *     viewing the object as a {@code CharSource}. This method is scheduled
++   *     for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static CharSource asCharSource(
++      final InputSupplier<? extends Readable> supplier) {
++    checkNotNull(supplier);
++    return new CharSource() {
++      @Override
++      public Reader openStream() throws IOException {
++        return asReader(supplier.getInput());
++      }
++
++      @Override
++      public String toString() {
++        return "CharStreams.asCharSource(" + supplier + ")";
++      }
++    };
++  }
++
++  /**
++   * Returns a view of the given {@code Appendable} supplier as a
++   * {@code CharSink}.
++   *
++   * <p>This method is a temporary method provided for easing migration from
++   * suppliers to sources and sinks.
++   *
++   * @since 15.0
++   * @deprecated Convert all {@code OutputSupplier<? extends Appendable>}
++   *     implementations to extend {@link CharSink} or provide a method for
++   *     viewing the object as a {@code CharSink}. This method is scheduled
++   *     for removal in Guava 18.0.
++   */
++  @Deprecated
++  public static CharSink asCharSink(
++      final OutputSupplier<? extends Appendable> supplier) {
++    checkNotNull(supplier);
++    return new CharSink() {
++      @Override
++      public Writer openStream() throws IOException {
++        return asWriter(supplier.getOutput());
++      }
++
++      @Override
++      public String toString() {
++        return "CharStreams.asCharSink(" + supplier + ")";
++      }
++    };
++  }
++
++  @SuppressWarnings("unchecked") // used internally where known to be safe
++  static <R extends Reader> InputSupplier<R> asInputSupplier(
++      CharSource source) {
++    return (InputSupplier) checkNotNull(source);
++  }
++
++  @SuppressWarnings("unchecked") // used internally where known to be safe
++  static <W extends Writer> OutputSupplier<W> asOutputSupplier(
++      CharSink sink) {
++    return (OutputSupplier) checkNotNull(sink);
++  }
+ }
diff --git a/debian/patches/series b/debian/patches/series
index 8972202..a935f21 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -3,3 +3,4 @@
 03-openjdk-inference.patch
 04-source-encoding.patch
 05-preserve-mapmaker-makecomputingmap.patch
+06-preserve-pre-guava18-methods.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/guava-libraries.git



More information about the pkg-java-commits mailing list