Class ComposableBody.Builder

java.lang.Object
org.igniterealtime.jbosh.ComposableBody.Builder
Enclosing class:
ComposableBody

public static final class ComposableBody.Builder extends 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 Details

  • Constructor Details

    • Builder

      private Builder()
      Prevent direct construction.
  • Method Details

    • fromBody

      private static ComposableBody.Builder fromBody(ComposableBody source)
      Creates a builder which is initialized to the values of the provided ComposableBody instance. This allows an existing ComposableBody to be used as a template/starting point.
      Parameters:
      source - body template
      Returns:
      builder instance
    • setPayloadXML

      public ComposableBody.Builder setPayloadXML(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, String value)
      Set an attribute on the message body / wrapper element.
      Parameters:
      name - qualified name of the attribute
      value - value of the attribute
      Returns:
      builder instance
    • setNamespaceDefinition

      public ComposableBody.Builder setNamespaceDefinition(String prefix, 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 define
      uri - 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