madkit.message

## Class XMLMessage

- java.lang.Object
- - madkit.kernel.Message
  - - madkit.message.XMLMessage

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

      public class XMLMessage
      extends Message

  A message that carries an XML document. You can set the document either through a string or a pre-parsed DOM tree. This class is optimized in the sense that it will change representations only if needed (i.e. constructed with a String and used through the getDocument() accessor).
  Since:
    MaDKit 1.0
  Version:
    5.0
  Author:
    Oliver Gutknecht, Jacques Ferber, Fabien Michel
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.w3c.dom.Document` | `docContent` The xml content as a Document (null if the content is defined as a string)
    `protected java.lang.String` | `strcontent` The xml content as a String (null if the content is defined as a Document)

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XMLMessage(org.w3c.dom.Document d)` Setup an XMLMessage with the xml document setup as a Document
    `XMLMessage(java.lang.String s)` Setup an XMLMessage with the xml document setup as a string.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.w3c.dom.Document` | `getDocument()` Returns the XMLMessage content as a document.
    `java.lang.String` | `getString()` Returns the XMLMessage content as a string.
    `java.lang.String` | `toString()` This method returns a string for the XML document set in this message.

    - ### Methods inherited from class madkit.kernel.Message

      `clone, getConversationID, getReceiver, getSender`

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

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

- - ### Field Detail

    - #### docContent

          protected org.w3c.dom.Document docContent

      The xml content as a Document (null if the content is defined as a string)

    - #### strcontent

          protected java.lang.String strcontent

      The xml content as a String (null if the content is defined as a Document)

  - ### Constructor Detail

    - #### XMLMessage

          public XMLMessage(java.lang.String s)

      Setup an XMLMessage with the xml document setup as a string. The string is not validated at construction
      Parameters:
        `s` - A valid (i.e. parseable) text XML document

    - #### XMLMessage

          public XMLMessage(org.w3c.dom.Document d)

      Setup an XMLMessage with the xml document setup as a Document
      Parameters:
        `d` - A well-formed DOM object

  - ### Method Detail

    - #### getString

          public java.lang.String getString()

      Returns the XMLMessage content as a string. If the String constructor was called, this accessor just returns the initial string. If the Document constructor was used, it transforms it to a String using JDOM
      Returns:
        A stringified version of the message content

    - #### getDocument

          public org.w3c.dom.Document getDocument()

      Returns the XMLMessage content as a document. If the Document constructor was called, this accessor just returns the initial document. If the String constructor was used, it uses JDOM to parse it into a DOM tree.
      Returns:
        A DOM object for the message content

    - #### toString

          public java.lang.String toString()

      This method returns a string for the XML document set in this message. Warning, if the document is directly stored as a Document and not a string, this will just call the toString() method on the Document object.
      Overrides:
        `toString` in class `Message`
      Returns:
        A stringified version of the document

Fabien Michel, Olivier Gutknecht, Jacques Ferber - November 18 2014