aboutsummaryrefslogtreecommitdiff
path: root/shared/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/main')
-rw-r--r--shared/src/main/java/com/google/archivepatcher/shared/ByteArrayInputStreamFactory.java36
-rw-r--r--shared/src/main/java/com/google/archivepatcher/shared/MultiViewInputStreamFactory.java10
-rw-r--r--shared/src/main/java/com/google/archivepatcher/shared/RandomAccessFileInputStreamFactory.java7
3 files changed, 44 insertions, 9 deletions
diff --git a/shared/src/main/java/com/google/archivepatcher/shared/ByteArrayInputStreamFactory.java b/shared/src/main/java/com/google/archivepatcher/shared/ByteArrayInputStreamFactory.java
new file mode 100644
index 0000000..0df3c1c
--- /dev/null
+++ b/shared/src/main/java/com/google/archivepatcher/shared/ByteArrayInputStreamFactory.java
@@ -0,0 +1,36 @@
+// Copyright 2016 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.archivepatcher.shared;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+/**
+ * A {@link MultiViewInputStreamFactory} which creates {@link ByteArrayInputStream}s based on the
+ * given {@code byte[]} in {@link #ByteArrayInputStreamFactory(byte[])}.
+ */
+public class ByteArrayInputStreamFactory implements MultiViewInputStreamFactory {
+
+ private final byte[] bytes;
+
+ public ByteArrayInputStreamFactory(byte[] bytes) {
+ this.bytes = bytes;
+ }
+
+ @Override
+ public ByteArrayInputStream newStream() throws IOException {
+ return new ByteArrayInputStream(bytes);
+ }
+}
diff --git a/shared/src/main/java/com/google/archivepatcher/shared/MultiViewInputStreamFactory.java b/shared/src/main/java/com/google/archivepatcher/shared/MultiViewInputStreamFactory.java
index f25dcc5..9b861b3 100644
--- a/shared/src/main/java/com/google/archivepatcher/shared/MultiViewInputStreamFactory.java
+++ b/shared/src/main/java/com/google/archivepatcher/shared/MultiViewInputStreamFactory.java
@@ -18,17 +18,17 @@ import java.io.IOException;
import java.io.InputStream;
/**
- * A factory that produces multiple independent but identical byte streams exposed via the
- * {@link InputStream} class.
- * @param <T> the type of {@link InputStream} that is produced
+ * A factory that produces multiple independent but identical byte streams exposed via the {@link
+ * InputStream} class.
*/
-public interface MultiViewInputStreamFactory<T extends InputStream> {
+public interface MultiViewInputStreamFactory {
/**
* Create and return a new {@link InputStream}. The returned stream is guaranteed to independently
* produce the same byte sequence as any other stream obtained via a call to this method on the
* same instance of this object.
+ *
* @return the stream
* @throws IOException if something goes wrong
*/
- public T newStream() throws IOException;
+ public InputStream newStream() throws IOException;
}
diff --git a/shared/src/main/java/com/google/archivepatcher/shared/RandomAccessFileInputStreamFactory.java b/shared/src/main/java/com/google/archivepatcher/shared/RandomAccessFileInputStreamFactory.java
index c153be8..0b5c89f 100644
--- a/shared/src/main/java/com/google/archivepatcher/shared/RandomAccessFileInputStreamFactory.java
+++ b/shared/src/main/java/com/google/archivepatcher/shared/RandomAccessFileInputStreamFactory.java
@@ -18,11 +18,10 @@ import java.io.File;
import java.io.IOException;
/**
- * An implementation of {@link MultiViewInputStreamFactory} that produces instances of
- * {@link RandomAccessFileInputStream}.
+ * An implementation of {@link MultiViewInputStreamFactory} that produces instances of {@link
+ * RandomAccessFileInputStream}.
*/
-public class RandomAccessFileInputStreamFactory
- implements MultiViewInputStreamFactory<RandomAccessFileInputStream> {
+public class RandomAccessFileInputStreamFactory implements MultiViewInputStreamFactory {
/**
* Argument for {@link RandomAccessFileInputStream#RandomAccessFileInputStream(File, long, long)}.