Class SpoilerElement

java.lang.Object
org.jivesoftware.smackx.spoiler.element.SpoilerElement
All Implemented Interfaces:
Element, ExtensionElement, NamedElement, XmlElement, XmlLangElement

public class SpoilerElement extends Object implements ExtensionElement
  • Field Details

  • Constructor Details

    • SpoilerElement

      public SpoilerElement(String language, String hint)
      Create a new SpoilerElement with a hint about a content and a language attribute.
      Parameters:
      language - language of the hint.
      hint - hint about the content.
  • Method Details

    • getHint

      public String getHint()
      Return the hint text of the spoiler. May be null.
      Returns:
      hint text
    • addSpoiler

      public static void addSpoiler(Message message)
      Add a SpoilerElement to a message.
      Parameters:
      message - message to add the Spoiler to.
    • addSpoiler

      public static void addSpoiler(Message message, String hint)
      Add a SpoilerElement with a hint to a message.
      Parameters:
      message - Message to add the Spoiler to.
      hint - Hint about the Spoilers content.
    • addSpoiler

      public static void addSpoiler(Message message, String lang, String hint)
      Add a SpoilerElement with a hint in a certain language to a message.
      Parameters:
      message - Message to add the Spoiler to.
      lang - language of the Spoiler hint.
      hint - hint.
    • containsSpoiler

      public static boolean containsSpoiler(Message message)
      Returns true, if the message has at least one spoiler element.
      Parameters:
      message - message
      Returns:
      true if message has spoiler extension
    • getSpoilers

      public static Map<String,String> getSpoilers(Message message)
      Return a map of all spoilers contained in a message. The map uses the language of a spoiler as key. If a spoiler has no language attribute, its key will be an empty String.
      Parameters:
      message - message
      Returns:
      map of spoilers
    • getLanguage

      public String getLanguage()
      Description copied from interface: XmlLangElement
      Returns the xml:lang of this XML element, or null if one has not been set.
      Specified by:
      getLanguage in interface XmlElement
      Specified by:
      getLanguage in interface XmlLangElement
      Returns:
      the xml:lang of this XML element, or null.
    • getNamespace

      public String getNamespace()
      Description copied from interface: XmlElement
      Returns the root element XML namespace.
      Specified by:
      getNamespace in interface XmlElement
      Returns:
      the namespace.
    • getElementName

      Description copied from interface: NamedElement
      Returns the root element name.
      Specified by:
      getElementName in interface NamedElement
      Returns:
      the element name.
    • toXML

      public CharSequence toXML(XmlEnvironment enclosingNamespace)
      Specified by:
      toXML in interface Element