You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/29 18:21:20 UTC

[2/4] git commit: Revert "Remove ByteArrayPayload"

Revert "Remove ByteArrayPayload"

This reverts commit ac2238364840915597b860e395973859b3f447ab.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/035d9d1e
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/035d9d1e
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/035d9d1e

Branch: refs/heads/master
Commit: 035d9d1ed7227075d870ed7becf16394fce7e5d5
Parents: 1702bdd
Author: Adrian Cole <ac...@twitter.com>
Authored: Tue Oct 28 15:47:01 2014 -0700
Committer: Adrian Cole <ad...@apache.org>
Committed: Wed Oct 29 10:20:39 2014 -0700

----------------------------------------------------------------------
 core/src/main/java/org/jclouds/io/Payloads.java |  9 ++++
 .../jclouds/io/payloads/ByteArrayPayload.java   | 49 ++++++++++++++++++++
 2 files changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/035d9d1e/core/src/main/java/org/jclouds/io/Payloads.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/io/Payloads.java b/core/src/main/java/org/jclouds/io/Payloads.java
index 1b4bb7a..1ccacf7 100644
--- a/core/src/main/java/org/jclouds/io/Payloads.java
+++ b/core/src/main/java/org/jclouds/io/Payloads.java
@@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import java.io.File;
 import java.io.InputStream;
 
+import org.jclouds.io.payloads.ByteArrayPayload;
 import org.jclouds.io.payloads.ByteSourcePayload;
 import org.jclouds.io.payloads.FilePayload;
 import org.jclouds.io.payloads.InputStreamPayload;
@@ -61,6 +62,14 @@ public class Payloads {
       return new InputStreamPayload(checkNotNull(data, "data"));
    }
 
+   /**
+    * @deprecated see newPayload(ByteSource)
+    */
+   @Deprecated
+   public static ByteArrayPayload newByteArrayPayload(byte[] data) {
+      return new ByteArrayPayload(checkNotNull(data, "data"));
+   }
+
    public static ByteSourcePayload newByteSourcePayload(ByteSource data) {
       return new ByteSourcePayload(checkNotNull(data, "data"));
    }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/035d9d1e/core/src/main/java/org/jclouds/io/payloads/ByteArrayPayload.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/jclouds/io/payloads/ByteArrayPayload.java b/core/src/main/java/org/jclouds/io/payloads/ByteArrayPayload.java
new file mode 100644
index 0000000..5bcf514
--- /dev/null
+++ b/core/src/main/java/org/jclouds/io/payloads/ByteArrayPayload.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.jclouds.io.payloads;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ * @deprecated see ByteSourcePayload
+ */
+@Deprecated
+public class ByteArrayPayload extends BasePayload<byte[]> {
+   public ByteArrayPayload(byte[] content) {
+      this(content, null);
+   }
+
+   public ByteArrayPayload(byte[] content, byte[] md5) {
+      super(content);
+      getContentMetadata().setContentLength(Long.valueOf(checkNotNull(content, "content").length));
+      getContentMetadata().setContentMD5(md5);
+      checkArgument(content.length >= 0, "length cannot me negative");
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public InputStream openStream() {
+      return new ByteArrayInputStream(content);
+   }
+
+}