Package org.opensaml.messaging.context

# Class MessageContext

java.lang.Object
org.opensaml.messaging.context.BaseContext
org.opensaml.messaging.context.MessageContext

All Implemented Interfaces:
  `Iterable<BaseContext>`

public final class MessageContext extends BaseContext
A context component which holds the state related to the processing of a single message.

Additional information associated with the message represented by the context may be held by the context as subordinate subcontext instances. Subcontext instances may simply hold state information related to the message, in which case they may be seen as a type-safe variant of the ubiquitous properties map pattern. They may also be more functional or operational in nature, for example providing "views" onto the message and/or message context data.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.opensaml.messaging.context.BaseContext

`BaseContext.ContextSetNoRemoveIteratorDecorator, BaseContext.DeprecatedContextClassNameLookAside`

## Field Summary

Fields
Modifier and Type
Field
Description
`private Object`
`msg`
The message represented.

## Constructor Summary

Constructors
Constructor
Description
`MessageContext()`

## Method Summary

Modifier and Type
Method
Description
`Object`
`ensureMessage()`
Get the message represented by the message context, raising a `ConstraintViolationException` if null.
`<T> T`
`ensureMessage(Class<T> claz)`
Get the message represented by the message context, raising a `ConstraintViolationException` or `ClassCastException` if the message is absent or of the incorrect type.
`Object`
`getMessage()`
Get the message represented by the message context.
`void`
`setMessage(Object message)`
Set the message represented by the message context.

### Methods inherited from class org.opensaml.messaging.context.BaseContext

`addSubcontext, addSubcontext, clearSubcontexts, containsSubcontext, createSubcontext, ensureSubcontext, ensureSubcontext, getParent, getSubcontext, getSubcontext, getSubcontext, getSubcontext, iterator, removeFromParent, removeSubcontext, removeSubcontext, setParent`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

## Field Details

### msg

@Nullable private Object msg
The message represented.

## Constructor Details

### MessageContext

public MessageContext()

## Method Details

### getMessage

@Nullable public Object getMessage()
Get the message represented by the message context.

Returns:
  the message or null

### ensureMessage

@Nonnull public Object ensureMessage()
Get the message represented by the message context, raising a `ConstraintViolationException` if null.

Returns:
  the message
Since:
  5.0.0

### ensureMessage

@Nonnull public <T> T ensureMessage(@Nonnull Class<T> claz)
Get the message represented by the message context, raising a `ConstraintViolationException` or `ClassCastException` if the message is absent or of the incorrect type.

Type Parameters:
  `T` - type of message
Parameters:
  `claz` - class of message type
Returns:
  properly typed message
Since:
  5.0.0

### setMessage

public void setMessage(@Nullable Object message)
Set the message represented by the message context.

Parameters:
  `message` - the message