org.nhindirect.stagent.mail
Class WrappedMessage

java.lang.Object
  extended by org.nhindirect.stagent.mail.WrappedMessage

public class WrappedMessage
extends Object

Utility class for wrapping a message according to the NHIN Direct agent specification.

Author:
Greg Meyer, Umesh Madan

Constructor Summary
WrappedMessage()
           
 
Method Summary
static Message create(Message message, String[] headersToCopy)
          Wraps a messaging into a new message by creating a message wrapper, copying only desired headers into the wrapper, and pushing the entire original message (including headers) into the body of the wrapper.
static Message create(String message, String[] headersToCopy)
          Wraps a messaging (represented in a raw string) into a new message by creating a message wrapper, copying only desired headers into the wrapper, and pushing the entire original message (including headers) into the body of the wrapper.
static Message extract(Message message)
          Extracts the wrapped message from the wrapper.
static boolean isWrapped(Message message)
          Determines if a message is wrapped.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WrappedMessage

public WrappedMessage()
Method Detail

create

public static Message create(Message message,
                             String[] headersToCopy)
                      throws javax.mail.MessagingException
Wraps a messaging into a new message by creating a message wrapper, copying only desired headers into the wrapper, and pushing the entire original message (including headers) into the body of the wrapper.

Parameters:
message - The message to wrap.
headersToCopy - The headers that should be copied from the original message into the wrapper.
Returns:
A message object that wraps the entire original entity (including headers) in its body.
Throws:
javax.mail.MessagingException

create

public static Message create(String message,
                             String[] headersToCopy)
                      throws javax.mail.MessagingException
Wraps a messaging (represented in a raw string) into a new message by creating a message wrapper, copying only desired headers into the wrapper, and pushing the entire original message (including headers) into the body of the wrapper.

Parameters:
message - The message to wrap.
headersToCopy - The headers that should be copied from the original message into the wrapper.
Returns:
A message object that wraps the entire original entity (including headers) in its body.
Throws:
javax.mail.MessagingException

isWrapped

public static boolean isWrapped(Message message)
Determines if a message is wrapped.

Parameters:
message - The message to check.
Returns:
Returns true if the message is determined to be a wrapped message. The wrapped message can be objected from the wrapper using the extract(Message)} operation.

extract

public static Message extract(Message message)
                       throws javax.mail.MessagingException
Extracts the wrapped message from the wrapper.

Parameters:
message - The message wrapper.
Returns:
The message that is contained inside the wrapper's body.
Throws:
javax.mail.MessagingException


Copyright © 2010-2015 NHIN Direct. All Rights Reserved.