Class StaticBody

java.lang.Object
org.igniterealtime.jbosh.AbstractBody
org.igniterealtime.jbosh.StaticBody

final class StaticBody extends AbstractBody
Implementation of the AbstractBody class which allows for the definition of messages from pre-existing message content. Instances of this class are based on the underlying data and therefore cannot be modified. In order to obtain the wrapper element namespace and attribute information, the body content is partially parsed.

This class does only minimal syntactic and semantic checking with respect to what the generated XML will look like. It is up to the developer to protect against the definition of malformed XML messages when building instances of this class.

Instances of this class are immutable and thread-safe.

  • Field Details

    • PARSER

      private static final BodyParser PARSER
      Selected parser to be used to process raw XML messages.
    • BUFFER_SIZE

      private static final int BUFFER_SIZE
      Size of the internal buffer when copying from a stream.
      See Also:
    • attrs

      private final Map<BodyQName,String> attrs
      Map of all attributes to their values.
    • raw

      private final String raw
      This body message in raw XML form.
  • Constructor Details

  • Method Details

    • fromStream

      public static StaticBody fromStream(InputStream inStream) throws BOSHException
      Creates an instance which is initialized by reading a body message from the provided stream.
      Parameters:
      inStream - stream to read message XML from
      Returns:
      body instance
      Throws:
      BOSHException - on parse error
    • fromString

      public static StaticBody fromString(String rawXML) throws BOSHException
      Creates an instance which is initialized by reading a body message from the provided raw XML string.
      Parameters:
      rawXML - raw message XML in string form
      Returns:
      body instance
      Throws:
      BOSHException - on parse error
    • getAttributes

      public Map<BodyQName,String> getAttributes()
      Get a map of all defined attribute names with their corresponding values.
      Specified by:
      getAttributes in class AbstractBody
      Returns:
      map of qualified attributes
    • toXML

      public String toXML()
      Get an XML String representation of this message.
      Specified by:
      toXML in class AbstractBody
      Returns:
      XML string representing the body message