Package com.helger.as2lib.client
Class AS2ClientRequest
- java.lang.Object
-
- com.helger.as2lib.client.AS2ClientRequest
-
public class AS2ClientRequest extends Object
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 Modifier and Type Field Description static StringDEFAULT_CONTENT_TYPE
-
Constructor Summary
Constructors Constructor Description AS2ClientRequest(String sSubject)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyDataOntoMimeBodyPart(jakarta.mail.internet.MimeBodyPart aPart)com.helger.mail.cte.EContentTransferEncodinggetContentTransferEncoding()StringgetContentType()StringgetSubject()AS2ClientRequestsetContentDescription(String sDescription)Set the optional Content-Description header to be used.AS2ClientRequestsetContentTransferEncoding(com.helger.mail.cte.EContentTransferEncoding eCTE)Set the optional Content-Transfer-Encoding to be used.AS2ClientRequestsetContentType(String sContentType)Set the content type to be used.AS2ClientRequestsetData(byte[] aData)Set the provided byte array as data.AS2ClientRequestsetData(jakarta.activation.DataHandler aDataHandler)Set the providedDataHandleras data.AS2ClientRequestsetData(File aFile, Charset aCharset)Set the content of theFileas a payload.AS2ClientRequestsetData(InputStream aIS)Set the content of theInputStreamas a payload.AS2ClientRequestsetData(InputStream aIS, Charset aCharset)Set the content of theInputStreamas a payload.AS2ClientRequestsetData(String sText, Charset aCharset)Set the provided String as data.AS2ClientRequestsetFilename(String sFilename)Set the filename to be used to name the content.
-
-
-
Field Detail
-
DEFAULT_CONTENT_TYPE
public static final String DEFAULT_CONTENT_TYPE
-
-
Method Detail
-
getSubject
@Nonnull @Nonempty public String getSubject()
- Returns:
- The subject as provided in the constructor. May neither be
nullnor empty.
-
setContentType
@Nonnull public AS2ClientRequest setContentType(@Nonnull @Nonempty String sContentType)
Set the content type to be used. Use this AFTERsetDatawas called, as this may select a default MIME type.- Parameters:
sContentType- The content type. May neither benullnor empty.- Returns:
- this
-
getContentType
@Nonnull @Nonempty public String getContentType()
- Returns:
- The content type to be used. Defaults to
DEFAULT_CONTENT_TYPE. Is overridden in thesetDatamethods.
-
setData
@Nonnull public AS2ClientRequest setData(@Nonnull File aFile, @Nullable Charset aCharset)
Set the content of theFileas 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-Fileto read the content from. Nevernull.aCharset- Charset to use. If it isnullthe content is set as a byte array, if notnullthe content is set as a String.- Returns:
- this
-
setData
@Nonnull public AS2ClientRequest setData(@Nonnull @WillClose InputStream aIS)
Set the content of theInputStreamas a payload. No charset is applied and therefore no content type starting with "text/" may be used.- Parameters:
aIS-InputStreamto read the content from. Nevernull.- Returns:
- this
-
setData
@Nonnull public AS2ClientRequest setData(@Nonnull @WillClose InputStream aIS, @Nullable Charset aCharset)
Set the content of theInputStreamas a payload. No charset is applied and therefore no content type starting with "text/" may be used.- Parameters:
aIS-InputStreamto read the content from. Nevernull.aCharset- Charset to use. If it isnullthe content is set as a byte array, if notnullthe content is set as a String.- Returns:
- this
-
setData
@Nonnull public AS2ClientRequest setData(@Nonnull byte[] aData)
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
@Nonnull public AS2ClientRequest setData(@Nonnull String sText, @Nullable Charset aCharset)
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
@Nonnull public AS2ClientRequest setData(@Nonnull jakarta.activation.DataHandler aDataHandler)
Set the providedDataHandleras 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
@Nonnull public AS2ClientRequest setFilename(@Nullable String sFilename)
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 benullto 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 benullin which case the default CTE is used.- Returns:
- this for chaining
- Since:
- 3.0.4
-
getContentTransferEncoding
@Nullable public com.helger.mail.cte.EContentTransferEncoding getContentTransferEncoding()
- Returns:
- The Content-Transfer-Encoding provided. May be
null. - Since:
- 4.1.1
-
setContentDescription
@Nonnull public AS2ClientRequest setContentDescription(@Nullable String sDescription)
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
-
-