You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by se...@apache.org on 2010/12/15 01:40:15 UTC

svn commit: r1049366 - /httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java

Author: sebb
Date: Wed Dec 15 00:40:15 2010
New Revision: 1049366

URL: http://svn.apache.org/viewvc?rev=1049366&view=rev
Log:
Javadoc

Modified:
    httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java

Modified: httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java?rev=1049366&r1=1049365&r2=1049366&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java (original)
+++ httpcomponents/httpcore/trunk/httpcore/src/main/java/org/apache/http/entity/StringEntity.java Wed Dec 15 00:40:15 2010
@@ -46,12 +46,19 @@ public class StringEntity extends Abstra
     protected final byte[] content;
 
     /**
+     * Creates a StringEntity with the specified content, mimetype and charset
+     * 
+     * @param string content to be used. Not {@code null}.
+     * @param mimeType mime type to be used. May be {@code null}, in which case the default is {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain"
+     * @param charset character set to be used. May be {@code null}, in which case the default is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
+     * 
      * @since 4.1
+     * @throws IllegalArgumentException if the string parameter is null
      */
-    public StringEntity(final String s, String mimeType, String charset)
+    public StringEntity(final String string, String mimeType, String charset)
             throws UnsupportedEncodingException {
         super();
-        if (s == null) {
+        if (string == null) {
             throw new IllegalArgumentException("Source string may not be null");
         }
         if (mimeType == null) {
@@ -60,18 +67,39 @@ public class StringEntity extends Abstra
         if (charset == null) {
             charset = HTTP.DEFAULT_CONTENT_CHARSET;
         }
-        this.content = s.getBytes(charset);
+        this.content = string.getBytes(charset);
         setContentType(mimeType + HTTP.CHARSET_PARAM + charset);
     }
 
-    public StringEntity(final String s, String charset)
+    /**
+     * Creates a StringEntity with the specified content and charset.
+     * <br/>
+     * The mime type defaults to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
+     * 
+     * @param string content to be used. Not {@code null}.
+     * @param charset character set to be used. May be {@code null}, in which case the default is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
+     * 
+     * @throws IllegalArgumentException if the string parameter is null
+     */
+    public StringEntity(final String string, String charset)
             throws UnsupportedEncodingException {
-        this(s, null, charset);
+        this(string, null, charset);
     }
 
-    public StringEntity(final String s)
+    /**
+     * Creates a StringEntity with the specified content and charset.
+     * <br/>
+     * The charset defaults to {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1".
+     * <br/>
+     * The mime type defaults to {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain".
+     * 
+     * @param string content to be used. Not {@code null}.
+     * 
+     * @throws IllegalArgumentException if the string parameter is null
+     */
+    public StringEntity(final String string)
             throws UnsupportedEncodingException {
-        this(s, null);
+        this(string, null);
     }
 
     public boolean isRepeatable() {