Package com.helger.as2lib.client
Class AS2ClientRequest
java.lang.Object
com.helger.as2lib.client.AS2ClientRequest
This class represents the content of an AS2 client request.
- Author:
- oleo Date: May 12, 2010 Time: 5:48:26 PM, Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyDataOntoMimeBodyPart
(jakarta.mail.internet.MimeBodyPart aPart) com.helger.mail.cte.EContentTransferEncoding
setContentDescription
(String sDescription) Set the optional Content-Description header to be used.setContentTransferEncoding
(com.helger.mail.cte.EContentTransferEncoding eCTE) Set the optional Content-Transfer-Encoding to be used.setContentType
(String sContentType) Set the content type to be used.setData
(byte[] aData) Set the provided byte array as data.setData
(jakarta.activation.DataHandler aDataHandler) Set the providedDataHandler
as data.Set the content of theFile
as a payload.setData
(InputStream aIS) Set the content of theInputStream
as a payload.setData
(InputStream aIS, Charset aCharset) Set the content of theInputStream
as a payload.Set the provided String as data.setFilename
(String sFilename) Set the filename to be used to name the content.
-
Field Details
-
DEFAULT_CONTENT_TYPE
-
-
Constructor Details
-
AS2ClientRequest
- Parameters:
sSubject
- The subject to use. May neither benull
nor empty. Has no impact on the MIME part creation. Just declarative.
-
-
Method Details
-
getSubject
- Returns:
- The subject as provided in the constructor. May neither be
null
nor empty.
-
setContentType
Set the content type to be used. Use this AFTERsetData
was called, as this may select a default MIME type.- Parameters:
sContentType
- The content type. May neither benull
nor empty.- Returns:
- this
-
getContentType
- Returns:
- The content type to be used. Defaults to
DEFAULT_CONTENT_TYPE
. Is overridden in thesetData
methods.
-
setData
Set the content of theFile
as a payload. If no charset is applied (null
) no content type starting with "text/" may be used. The name of the file is used as the payload file name.- Parameters:
aFile
-File
to read the content from. Nevernull
.aCharset
- Charset to use. If it isnull
the content is set as a byte array, if notnull
the content is set as a String.- Returns:
- this
-
setData
Set the content of theInputStream
as a payload. No charset is applied and therefore no content type starting with "text/" may be used.- Parameters:
aIS
-InputStream
to read the content from. Nevernull
.- Returns:
- this
-
setData
@Nonnull public AS2ClientRequest setData(@Nonnull @WillClose InputStream aIS, @Nullable Charset aCharset) Set the content of theInputStream
as a payload. No charset is applied and therefore no content type starting with "text/" may be used.- Parameters:
aIS
-InputStream
to read the content from. Nevernull
.aCharset
- Charset to use. If it isnull
the content is set as a byte array, if notnull
the content is set as a String.- Returns:
- this
-
setData
Set the provided byte array as data. The "Content-Type" is set to "application/octet-stream".- Parameters:
aData
- The data to be used. May not benull
.- Returns:
- this for chaining.
-
setData
Set the provided String as data. The "Content-Type" is set to "text/plain".- Parameters:
sText
- The data to be used. May not benull
.aCharset
- The charset to be used. May benull
.- Returns:
- this for chaining.
-
setData
Set the providedDataHandler
as data. The "Content-Type" is directly taken from the provided handler.- Parameters:
aDataHandler
- The data handler to be used. May not benull
.- Returns:
- this for chaining.
-
setFilename
Set the filename to be used to name the content. This will add aContent-Disposition: attachment; filename=...
header to the MIME part- Parameters:
sFilename
- Filename to use. May benull
to indicate none (also the default)- Returns:
- this
-
setContentTransferEncoding
@Nonnull public AS2ClientRequest setContentTransferEncoding(@Nullable com.helger.mail.cte.EContentTransferEncoding eCTE) Set the optional Content-Transfer-Encoding to be used. By default it is determined by the data type that defines the body.- Parameters:
eCTE
- CTE to be used. May benull
in which case the default CTE is used.- Returns:
- this for chaining
- Since:
- 3.0.4
-
getContentTransferEncoding
- Returns:
- The Content-Transfer-Encoding provided. May be
null
. - Since:
- 4.1.1
-
setContentDescription
Set the optional Content-Description header to be used. By default non is present.- Parameters:
sDescription
- Content description to be used. May benull
.- Returns:
- this for chaining
- Since:
- 3.0.4
-
applyDataOntoMimeBodyPart
public void applyDataOntoMimeBodyPart(@Nonnull jakarta.mail.internet.MimeBodyPart aPart) throws jakarta.mail.MessagingException - Throws:
jakarta.mail.MessagingException
-