You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/08/09 12:59:37 UTC

svn commit: r1155304 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/main/java/org/apache/http/nio/entity/ httpcore/src/main/java/org/apache/http/entity/

Author: olegk
Date: Tue Aug  9 10:59:37 2011
New Revision: 1155304

URL: http://svn.apache.org/viewvc?rev=1155304&view=rev
Log:
Added constructor with ContentType parameter

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java?rev=1155304&r1=1155303&r2=1155304&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NByteArrayEntity.java Tue Aug  9 10:59:37 2011
@@ -35,6 +35,7 @@ import java.nio.ByteBuffer;
 
 import org.apache.http.annotation.NotThreadSafe;
 import org.apache.http.entity.AbstractHttpEntity;
+import org.apache.http.entity.ContentType;
 import org.apache.http.nio.ContentEncoder;
 import org.apache.http.nio.IOControl;
 import org.apache.http.nio.protocol.AsyncNHttpServiceHandler;
@@ -57,7 +58,10 @@ public class NByteArrayEntity extends Ab
     @Deprecated
     protected final ByteBuffer buffer;
 
-    public NByteArrayEntity(final byte[] b) {
+    /**
+     * @since 4.2
+     */
+    public NByteArrayEntity(final byte[] b, final ContentType contentType) {
         super();
         if (b == null) {
             throw new IllegalArgumentException("Source byte array may not be null");
@@ -68,9 +72,15 @@ public class NByteArrayEntity extends Ab
         this.buf = ByteBuffer.wrap(b);
         this.content = b;
         this.buffer = this.buf;
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
     }
 
-    public NByteArrayEntity(final byte[] b, int off, int len) {
+    /**
+     * @since 4.2
+     */
+    public NByteArrayEntity(final byte[] b, int off, int len, final ContentType contentType) {
         super();
         if (b == null) {
             throw new IllegalArgumentException("Source byte array may not be null");
@@ -85,6 +95,17 @@ public class NByteArrayEntity extends Ab
         this.buf = ByteBuffer.wrap(b, off, len);
         this.content = b;
         this.buffer = this.buf;
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
+    }
+
+    public NByteArrayEntity(final byte[] b) {
+        this(b, null);
+    }
+
+    public NByteArrayEntity(final byte[] b, int off, int len) {
+        this(b, off, len, null);
     }
 
     public void finish() {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java?rev=1155304&r1=1155303&r2=1155304&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/nio/entity/NFileEntity.java Tue Aug  9 10:59:37 2011
@@ -83,6 +83,15 @@ public class NFileEntity extends Abstrac
     }
 
     /**
+     * @since 4.2
+     */
+    public NFileEntity(final File file) {
+        if (file == null) {
+            throw new IllegalArgumentException("File may not be null");
+        }
+        this.file = file;
+    }
+    /**
      * Creates new instance of NFileEntity from the given source {@link File}
      * with the given content type.
      *

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java?rev=1155304&r1=1155303&r2=1155304&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/ByteArrayEntity.java Tue Aug  9 10:59:37 2011
@@ -47,7 +47,10 @@ public class ByteArrayEntity extends Abs
     private final byte[] b;
     private final int off, len;
 
-    public ByteArrayEntity(final byte[] b) {
+    /**
+     * @since 4.2
+     */
+    public ByteArrayEntity(final byte[] b, final ContentType contentType) {
         super();
         if (b == null) {
             throw new IllegalArgumentException("Source byte array may not be null");
@@ -56,9 +59,15 @@ public class ByteArrayEntity extends Abs
         this.b = b;
         this.off = 0;
         this.len = this.b.length;
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
     }
 
-    public ByteArrayEntity(final byte[] b, final int off, final int len) {
+    /**
+     * @since 4.2
+     */
+    public ByteArrayEntity(final byte[] b, int off, int len, final ContentType contentType) {
         super();
         if (b == null) {
             throw new IllegalArgumentException("Source byte array may not be null");
@@ -71,6 +80,17 @@ public class ByteArrayEntity extends Abs
         this.b = b;
         this.off = off;
         this.len = len;
+        if (contentType != null) {
+            setContentType(contentType.toString());
+        }
+    }
+
+    public ByteArrayEntity(final byte[] b) {
+        this(b, null);
+    }
+
+    public ByteArrayEntity(final byte[] b, int off, int len) {
+        this(b, off, len, null);
     }
 
     public boolean isRepeatable() {

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java?rev=1155304&r1=1155303&r2=1155304&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/FileEntity.java Tue Aug  9 10:59:37 2011
@@ -72,6 +72,17 @@ public class FileEntity extends Abstract
         }
     }
 
+    /**
+     * @since 4.2
+     */
+    public FileEntity(final File file) {
+        super();
+        if (file == null) {
+            throw new IllegalArgumentException("File may not be null");
+        }
+        this.file = file;
+    }
+
     public boolean isRepeatable() {
         return true;
     }