AS2Message

public class AS2Message

AS2Message represents an AS2 message.

Author:Hugo Y. K. Lam

Constructors

AS2Message

public AS2Message()

Creates a new instance of AS2Message.

AS2Message

public AS2Message(InputStream message)

Creates a new instance of AS2Message.

Parameters:
  • message – the message as input stream.
Throws:
  • AS2MessageException – if unable to construct from the given input stream.

AS2Message

public AS2Message(InternetHeaders headers, InputStream content)

Creates a new instance of AS2Message.

Parameters:
  • headers – the headers of this message.
  • content – the content stream.
Throws:
  • AS2MessageException – if unable to construct from the given content stream.

Methods

addHeader

public void addHeader(String name, String value)

Adds a message header of the specified name.

Parameters:
  • name – the header name.
  • value – the header value.

generateID

public static String generateID()

Generates a new AS2 message ID.

Returns:a new AS2 message ID.

getBodyPart

public MimeBodyPart getBodyPart()

Gets the MIME body part of this message.

Returns:the MIME body part.

getContent

public Object getContent()

Gets the content of this message.

Throws:
Returns:

the content part.

getContentStream

public InputStream getContentStream()

Gets the content stream of this message.

Throws:
Returns:

the content stream of this message.

getContentType

public String getContentType()

Gets the content type.

Throws:
Returns:

the content type.

getDispositionNotification

public DispositionNotification getDispositionNotification()

Gets the MDN of this message.

Throws:
Returns:

the MDN.

getDispositionNotificationOptions

public DispositionNotificationOptions getDispositionNotificationOptions()

Gets the disposition notification options.

Returns:the disposition notification options.

getFromPartyID

public String getFromPartyID()

Gets the “from” party ID.

Returns:the “from” party ID.

getHeader

public String getHeader(String name)

Gets a message header of the specified name.

Parameters:
  • name – the header name.
Returns:

the header value.

getHeader

public String getHeader(String name, String def)

Gets a message header of the specified name.

Parameters:
  • name – the header name.
  • def – the default value.
Returns:

the header value.

getHeaders

public InternetHeaders getHeaders()

Gets the headers of this message.

Returns:a copy of the headers of this message.

getInputStream

public InputStream getInputStream()

Gets the input stream of this message’s content. Any transfer encodings will be decoded before the input stream is provided.

Throws:
Returns:

the input stream of this message’s content.

getMessageID

public String getMessageID()

Gets the message ID.

Returns:the message ID.

getToPartyID

public String getToPartyID()

Gets the “to” party ID.

Returns:the “to” party ID.

isDispositionNotification

public boolean isDispositionNotification()

Checks if this message is an MDN.

Returns:true if this message is an MDN.

isReceiptRequested

public boolean isReceiptRequested()

Checks if receipt of message is requested.

Returns:true if receipt of message is requested.

isReceiptSynchronous

public boolean isReceiptSynchronous()

Checks if the receipt of message should be sent synchronously.

Returns:true if the receipt of message should be sent synchronously.

removeHeader

public void removeHeader(String name)

Removes a message header of the specified name.

Parameters:
  • name – the header name.

reply

public AS2Message reply()

Replies this message.

Throws:
Returns:

the reply message.

requestReceipt

public void requestReceipt(String returnUrl, String micAlg)

setBodyPart

public void setBodyPart(MimeBodyPart bp)

Sets the MIME body part of this message.

setContent

public void setContent(Object content, String contentType)

Sets a content to this message.

Parameters:
  • content – the content part.
  • contentType – the content type.
Throws:

setFromPartyID

public void setFromPartyID(String id)

setHeader

public void setHeader(String name, String value)

Sets a message header of the specified name.

Parameters:
  • name – the header name.
  • value – the header value.

setMessageID

public void setMessageID(String id)

setToPartyID

public void setToPartyID(String id)

toByteArray

public byte[] toByteArray()

Returns a byte array which represents this message.

Throws:
Returns:

a byte array which represents this message.

toString

public String toString()

Returns a string representation of this message.

Returns:a string representation of this message.

See also: java.lang.Object.toString()

writeTo

public void writeTo(OutputStream outs)

Writes the message to the given output stream.

Parameters:
  • outs – the output stream to be written.
Throws: