Class MessageContext
java.lang.Object
org.deltava.mail.MessageContext
A class to store and retrieve message context data.
- Since:
- 1.0
- Version:
- 11.1
- Author:
- Luke
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes the Message Context, and sets any pre-defined context elements.MessageContext
(String aCode) Initializes the Message Context, and sets any pre-defined context elements. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an object to the context data.(package private) Object
Determines the value of a given macro argument via recursive reflection.(package private) String
Evalutes and formats a given macro argument.getBody()
Formats the message by replacing arguments in the message template with values from the context.Returns the message subject.Returns the Message template in use.(package private) boolean
Checks if a particular named object exists within this context.void
Sets the message body to use, if no template is used.void
Sets the recipient of this email message.void
setSubject
(String subj) Overrides the subject used in the message, instead of using the Message Template subject.void
Sets the message template to use.
-
Constructor Details
-
MessageContext
public MessageContext()Initializes the Message Context, and sets any pre-defined context elements. -
MessageContext
Initializes the Message Context, and sets any pre-defined context elements.- Parameters:
aCode
- the airline code
-
-
Method Details
-
addData
Adds an object to the context data.- Parameters:
name
- the name of the objectobj
- the object- Throws:
NullPointerException
- if name is null
-
setSubject
Overrides the subject used in the message, instead of using the Message Template subject.- Parameters:
subj
- the new subject
-
getSubject
Returns the message subject.- Returns:
- the subject prepended by the Airline Name
-
getBody
Formats the message by replacing arguments in the message template with values from the context.- Returns:
- the formatted message body text
- Throws:
IllegalStateException
- if no template exists
-
hasData
Checks if a particular named object exists within this context.- Parameters:
name
- the name of the object- Returns:
- TRUE if the object exists within this context, otherwise false
- Throws:
NullPointerException
- if name is null
-
setRecipient
Sets the recipient of this email message.- Parameters:
to
- an EMailAddress
-
setBody
Sets the message body to use, if no template is used.- Parameters:
body
- the message body
-
setTemplate
Sets the message template to use.- Parameters:
mt
- the Message Template- See Also:
-
getTemplate
Returns the Message template in use.- Returns:
- a MessageTemplate object
- See Also:
-
execute
-
evaluate
Determines the value of a given macro argument via recursive reflection. The argument is in the following format: name.[method OR field ...] which can be repeated numerous times. For example the macro pirep.getAirportA.getIATA will get the named object called "pirep", and then execute the getAirportA() method on this object. The method getIATA() method will be returned on the result of the first method call. If no method matching a given name is found, a field with this name will be used if present. If no method or field matching a given component is found, then execution fails.- Parameters:
arg
- the argument macro- Returns:
- the value of the argument macro, or an empty String ("") if execution fails
- See Also:
-