@@ -43,36 +43,48 @@ public class StringPart extends PartBase {
43
43
private final byte [] content ;
44
44
private final String value ;
45
45
46
- public StringPart (String name , String value , Charset charset ) {
47
- this (name , value , charset , null );
48
- }
49
-
50
46
private static Charset charsetOrDefault (Charset charset ) {
51
47
return charset == null ? DEFAULT_CHARSET : charset ;
52
48
}
49
+
50
+ private static String contentTypeOrDefault (String contentType ) {
51
+ return contentType == null ? DEFAULT_CONTENT_TYPE : contentType ;
52
+ }
53
+
54
+ private static String transferEncodingOrDefault (String transferEncoding ) {
55
+ return transferEncoding == null ? DEFAULT_TRANSFER_ENCODING : transferEncoding ;
56
+ }
57
+
58
+ public StringPart (String name , String value ) {
59
+ this (name , value , null );
60
+ }
53
61
54
- /**
55
- * Constructor.
56
- *
57
- * @param name
58
- * The name of the part
59
- * @param value
60
- * the string to post
61
- * @param charset
62
- * the charset to be used to encode the string, if <code>null</code> the {@link #DEFAULT_CHARSET default} is used
63
- * @param contentId
64
- * the content id
65
- */
66
- public StringPart (String name , String value , Charset charset , String contentId ) {
67
- super (name , DEFAULT_CONTENT_TYPE , charsetOrDefault (charset ), contentId , DEFAULT_TRANSFER_ENCODING );
62
+ public StringPart (String name , String value , String contentType ) {
63
+ this (name , value , contentType , null );
64
+ }
65
+
66
+ public StringPart (String name , String value , String contentType , Charset charset ) {
67
+ this (name , value , contentType , charset , null );
68
+ }
69
+
70
+ public StringPart (String name , String value , String contentType , Charset charset , String fileName ) {
71
+ this (name , value , contentType , charset , fileName , null );
72
+ }
73
+
74
+ public StringPart (String name , String value , String contentType , Charset charset , String fileName , String contentId ) {
75
+ this (name , value , contentType , charset , fileName , contentId , null );
76
+ }
77
+
78
+ public StringPart (String name , String value , String contentType , Charset charset , String fileName , String contentId , String transferEncoding ) {
79
+ super (name , contentTypeOrDefault (contentType ), charsetOrDefault (charset ), contentId , transferEncodingOrDefault (transferEncoding ));
68
80
if (value == null )
69
81
throw new NullPointerException ("value" );
70
82
71
83
if (value .indexOf (0 ) != -1 )
72
84
// See RFC 2048, 2.8. "8bit Data"
73
85
throw new IllegalArgumentException ("NULs may not be present in string parts" );
74
86
75
- content = value .getBytes (charsetOrDefault ( charset ));
87
+ content = value .getBytes (getCharset ( ));
76
88
this .value = value ;
77
89
}
78
90
0 commit comments