public class Entity extends Object
| Constructor and Description |
|---|
Entity() |
Entity(org.ballerinalang.jvm.values.ObjectValue entity) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String headerName,
String headerValue)
Adds the specified header to the entity.
|
Entity[] |
getBodyParts()
Given an entity, gets its body parts.
|
byte[] |
getByteArray()
Gets the entity payload as a `byte[]`.
|
ByteChannel |
getByteChannel()
Given an entity, gets the entity body as a byte channel.
|
org.ballerinalang.jvm.values.ObjectValue |
getEntityObj()
Returns the java native object of the ballerina level mime:Entity object.
|
String |
getHeader(String headerName)
Returns the value of the specified header.
|
String[] |
getHeaderNames()
Gets all the names of the headers of the entity.
|
String[] |
getHeaders(String headerName)
Gets all the header values to which the specified header key maps to.
|
org.json.JSONObject |
getJson()
Extracts `json` payload from the entity.
|
org.json.JSONArray |
getJsonArray()
Extracts `json array` payload from the entity.
|
String |
getText()
Extracts `text` payload from the entity.
|
org.ballerinalang.jvm.values.api.BXML |
getXml()
Extracts `xml` payload from the entity.
|
boolean |
hasHeader(String headerName)
Checks whether the requested header key exists in the header map.
|
void |
removeAllHeaders()
Removes all the headers from the entity.
|
void |
removeHeader(String headerName)
Removes the specified header from the entity.
|
void |
setBinary(byte[] binaryPayload)
Sets a byte[] content to the entity.
|
void |
setBodyParts(Entity[] bodyParts,
String contentType)
Set multiparts as the payload.
|
void |
setByteChannel(org.ballerinalang.stdlib.io.channels.base.Channel channel,
String contentType)
Sets a `ByteChannel` to the entity.
|
void |
setHeader(String headerName,
String headerValue)
Sets the specified header to the entity.
|
void |
setJson(org.json.JSONArray jsonArrayPayload)
Sets a json array
JSONArray as the payload to the entity. |
void |
setJson(org.json.JSONObject jsonPayload)
Sets a json
JSONObject as the payload to the entity. |
void |
setText(String textPayload)
Sets a string text content to the entity.
|
void |
setXml(org.ballerinalang.jvm.values.api.BXML xmlPayload)
Sets a xml to the entity.
|
public Entity(org.ballerinalang.jvm.values.ObjectValue entity)
public Entity()
public boolean hasHeader(String headerName)
headerName - The header name.public String getHeader(String headerName)
headerName - The header name.public String[] getHeaders(String headerName)
headerName - The header name.public void setHeader(String headerName, String headerValue)
headerName - The header name.headerValue - The header value.public void addHeader(String headerName, String headerValue)
headerName - The header name.headerValue - The header value.public void removeHeader(String headerName)
headerName - The header name.public void removeAllHeaders()
public String[] getHeaderNames()
public org.json.JSONObject getJson()
throws InterceptorException
InterceptorException - If error while getting json payload.public org.json.JSONArray getJsonArray()
throws InterceptorException
InterceptorException - If error while getting json payload.public org.ballerinalang.jvm.values.api.BXML getXml()
throws InterceptorException
BXML The `xml` payload of the request.InterceptorException - If error while getting xml payload.public String getText() throws InterceptorException
InterceptorException - If error while getting text payload.public ByteChannel getByteChannel() throws InterceptorException
ByteChannel A byte channel from which the message payload can be read.InterceptorException - If error while getting byte channel of the entity.public byte[] getByteArray()
throws InterceptorException
InterceptorException - If error while getting byte array of the entity.public Entity[] getBodyParts() throws InterceptorException
Entity[] extracted from the entity bodyInterceptorException - If error while getting byte array of the entity.public void setJson(org.json.JSONObject jsonPayload)
JSONObject as the payload to the entity.jsonPayload - JSONObject The json payload.public void setJson(org.json.JSONArray jsonArrayPayload)
JSONArray as the payload to the entity.jsonArrayPayload - JSONArray The json payload.public void setXml(org.ballerinalang.jvm.values.api.BXML xmlPayload)
xmlPayload - The xml BXML payload.public void setText(String textPayload)
textPayload - The text payload.public void setBinary(byte[] binaryPayload)
binaryPayload - The byte[] payload.public void setBodyParts(Entity[] bodyParts, String contentType)
bodyParts - The entities which make up the message bodycontentType - The content type of the top level message. Set this to override the default
`content-type` header value which is 'multipart/form-data'public void setByteChannel(org.ballerinalang.stdlib.io.channels.base.Channel channel,
String contentType)
channel - - A `ByteChannel` Channel through which the message payload can be readcontentType - The content type of the top level message. Set this to override the default
`content-type` header value which is 'application/octet-stream'public org.ballerinalang.jvm.values.ObjectValue getEntityObj()
ObjectValue representing the entity.Copyright © 2021 WSO2. All rights reserved.