StringPartpublic class StringPart extends PartBase Simple string parameter for a multipart post |
Fields Summary |
---|
private static final Log | LOGLog object for this class. | public static final String | DEFAULT_CONTENT_TYPEDefault content encoding of string parameters. | public static final String | DEFAULT_CHARSETDefault charset of string parameters | public static final String | DEFAULT_TRANSFER_ENCODINGDefault transfer encoding of string parameters | private byte[] | contentContents of this StringPart. | private String | valueThe String value of this part. |
Constructors Summary |
---|
public StringPart(String name, String value, String charset)Constructor.
super(
name,
DEFAULT_CONTENT_TYPE,
charset == null ? DEFAULT_CHARSET : charset,
DEFAULT_TRANSFER_ENCODING
);
if (value == null) {
throw new IllegalArgumentException("Value may not be null");
}
if (value.indexOf(0) != -1) {
// See RFC 2048, 2.8. "8bit Data"
throw new IllegalArgumentException("NULs may not be present in string parts");
}
this.value = value;
| public StringPart(String name, String value)Constructor.
this(name, value, null);
|
Methods Summary |
---|
private byte[] | getContent()Gets the content in bytes. Bytes are lazily created to allow the charset to be changed
after the part is created.
if (content == null) {
content = EncodingUtils.getBytes(value, getCharSet());
}
return content;
| protected long | lengthOfData()Return the length of the data.
LOG.trace("enter lengthOfData()");
return getContent().length;
| protected void | sendData(java.io.OutputStream out)Writes the data to the given OutputStream.
LOG.trace("enter sendData(OutputStream)");
out.write(getContent());
| public void | setCharSet(java.lang.String charSet)
super.setCharSet(charSet);
this.content = null;
|
|