Package org.igniterealtime.jbosh
Class ComposableBody.Builder
- java.lang.Object
-
- org.igniterealtime.jbosh.ComposableBody.Builder
-
- Enclosing class:
- ComposableBody
public static final class ComposableBody.Builder extends java.lang.Object
Class instance builder, after the builder pattern. This allows each message instance to be immutable while providing flexibility when building new messages. Instances of this class are not thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
doMapCopy
private java.util.Map<BodyQName,java.lang.String>
map
private java.lang.String
payloadXML
-
Constructor Summary
Constructors Modifier Constructor Description private
Builder()
Prevent direct construction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ComposableBody
build()
Build the immutable object instance with the current configuration.private static ComposableBody.Builder
fromBody(ComposableBody source)
Creates a builder which is initialized to the values of the providedComposableBody
instance.ComposableBody.Builder
setAttribute(BodyQName name, java.lang.String value)
Set an attribute on the message body / wrapper element.ComposableBody.Builder
setNamespaceDefinition(java.lang.String prefix, java.lang.String uri)
Convenience method to set a namespace definition.ComposableBody.Builder
setPayloadXML(java.lang.String xml)
Set the body message's wrapped payload content.
-
-
-
Field Detail
-
map
private java.util.Map<BodyQName,java.lang.String> map
-
doMapCopy
private boolean doMapCopy
-
payloadXML
private java.lang.String payloadXML
-
-
Method Detail
-
fromBody
private static ComposableBody.Builder fromBody(ComposableBody source)
Creates a builder which is initialized to the values of the providedComposableBody
instance. This allows an existingComposableBody
to be used as a template/starting point.- Parameters:
source
- body template- Returns:
- builder instance
-
setPayloadXML
public ComposableBody.Builder setPayloadXML(java.lang.String xml)
Set the body message's wrapped payload content. Any previous content will be replaced.- Parameters:
xml
- payload XML content- Returns:
- builder instance
-
setAttribute
public ComposableBody.Builder setAttribute(BodyQName name, java.lang.String value)
Set an attribute on the message body / wrapper element.- Parameters:
name
- qualified name of the attributevalue
- value of the attribute- Returns:
- builder instance
-
setNamespaceDefinition
public ComposableBody.Builder setNamespaceDefinition(java.lang.String prefix, java.lang.String uri)
Convenience method to set a namespace definition. This would result in a namespace prefix definition similar to:<body xmlns:prefix="uri"/>
- Parameters:
prefix
- prefix to defineuri
- namespace URI to associate with the prefix- Returns:
- builder instance
-
build
public ComposableBody build()
Build the immutable object instance with the current configuration.- Returns:
- composable body instance
-
-