Class SimpleBody
- java.lang.Object
-
- org.apache.hc.client5.http.async.methods.SimpleBody
-
public final class SimpleBody extends java.lang.ObjectMessage body representation as a simple text string or an array of bytes.- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]bodyAsBytesprivate java.lang.StringbodyAsTextprivate org.apache.hc.core5.http.ContentTypecontentType
-
Constructor Summary
Constructors Constructor Description SimpleBody(byte[] bodyAsBytes, java.lang.String bodyAsText, org.apache.hc.core5.http.ContentType contentType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static SimpleBodycreate(byte[] body, org.apache.hc.core5.http.ContentType contentType)(package private) static SimpleBodycreate(java.lang.String body, org.apache.hc.core5.http.ContentType contentType)byte[]getBodyBytes()Gets the body as a byte array.java.lang.StringgetBodyText()Gets the body as a String.org.apache.hc.core5.http.ContentTypegetContentType()Gets the content type.booleanisBytes()Tests whether the body is currently cached as a byte array.booleanisText()Tests whether the body is currently cached as a String.java.lang.StringtoString()
-
-
-
Method Detail
-
create
static SimpleBody create(java.lang.String body, org.apache.hc.core5.http.ContentType contentType)
-
create
static SimpleBody create(byte[] body, org.apache.hc.core5.http.ContentType contentType)
-
getContentType
public org.apache.hc.core5.http.ContentType getContentType()
Gets the content type.- Returns:
- the content type.
-
getBodyBytes
public byte[] getBodyBytes()
Gets the body as a byte array.- Returns:
- the body as a byte array.
-
getBodyText
public java.lang.String getBodyText()
Gets the body as a String.- Returns:
- the body as a String.
-
isText
public boolean isText()
Tests whether the body is currently cached as a String.- Returns:
- whether the body is currently cached as a String.
-
isBytes
public boolean isBytes()
Tests whether the body is currently cached as a byte array.- Returns:
- whether the body is currently cached as a byte array.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-