Class StanzaBuilder<B extends StanzaBuilder<B>>

java.lang.Object
org.jivesoftware.smack.packet.StanzaBuilder<B>
All Implemented Interfaces:
StanzaView, XmlLangElement
Direct Known Subclasses:
AbstractIqBuilder, MessageOrPresenceBuilder

public abstract class StanzaBuilder<B extends StanzaBuilder<B>> extends Object implements StanzaView
  • Constructor Details

    • StanzaBuilder

      protected StanzaBuilder(StanzaBuilder<?> other)
    • StanzaBuilder

      protected StanzaBuilder(StanzaIdSource stanzaIdSource)
    • StanzaBuilder

      protected StanzaBuilder(String stanzaId)
    • StanzaBuilder

      protected StanzaBuilder(Stanza message, String stanzaId)
    • StanzaBuilder

      protected StanzaBuilder(Stanza message, StanzaIdSource stanzaIdSource)
  • Method Details

    • to

      public final B to(CharSequence to) throws org.jxmpp.stringprep.XmppStringprepException
      Set the recipient address of the stanza.
      Parameters:
      to - whom the stanza is being sent.
      Returns:
      a reference to this builder.
      Throws:
      org.jxmpp.stringprep.XmppStringprepException - if the provided character sequence is not a valid XMPP address.
      See Also:
    • to

      public final B to(org.jxmpp.jid.Jid to)
      Sets who the stanza is being sent "to". The XMPP protocol often makes the "to" attribute optional, so it does not always need to be set.
      Parameters:
      to - who the stanza is being sent to.
      Returns:
      a reference to this builder.
    • from

      public final B from(CharSequence from) throws org.jxmpp.stringprep.XmppStringprepException
      Sets who the stanza is being sent "from".
      Parameters:
      from - who the stanza is being sent from.
      Returns:
      a reference to this builder.
      Throws:
      org.jxmpp.stringprep.XmppStringprepException - if the provided character sequence is not a valid XMPP address.
      See Also:
    • from

      public final B from(org.jxmpp.jid.Jid from)
      Sets who the stanza is being sent "from". The XMPP protocol often makes the "from" attribute optional, so it does not always need to be set.
      Parameters:
      from - who the stanza is being sent from.
      Returns:
      a reference to this builder.
    • setError

      public final B setError(StanzaError stanzaError)
      Sets the error for this stanza.
      Parameters:
      stanzaError - the error to associate with this stanza.
      Returns:
      a reference to this builder.
    • setLanguage

      public final B setLanguage(String language)
      Sets the xml:lang for this stanza.
      Parameters:
      language - the xml:lang of this stanza.
      Returns:
      a reference to this builder.
    • addExtension

      public final B addExtension(XmlElement extensionElement)
    • addOptExtensions

      public final B addOptExtensions(Collection<? extends XmlElement> extensionElements)
    • addExtensions

      public final B addExtensions(Collection<? extends XmlElement> extensionElements)
    • overrideExtension

      public final B overrideExtension(XmlElement extensionElement)
    • removeExtension

      public final B removeExtension(String elementName, String namespace)
    • removeExtension

      public final B removeExtension(ExtensionElement extension)
    • build

      public abstract Stanza build()
    • getThis

      public abstract B getThis()
    • getStanzaId

      public final String getStanzaId()
      Description copied from interface: StanzaView
      Returns the unique ID of the stanza. The returned value could be null.
      Specified by:
      getStanzaId in interface StanzaView
      Returns:
      the packet's unique ID or null if the id is not available.
    • getTo

      public final org.jxmpp.jid.Jid getTo()
      Description copied from interface: StanzaView
      Returns who the stanza is being sent "to", or null if the value is not set. The XMPP protocol often makes the "to" attribute optional, so it does not always need to be set.
      Specified by:
      getTo in interface StanzaView
      Returns:
      who the stanza is being sent to, or null if the value has not been set.
    • getFrom

      public final org.jxmpp.jid.Jid getFrom()
      Description copied from interface: StanzaView
      Returns who the stanza is being sent "from" or null if the value is not set. The XMPP protocol often makes the "from" attribute optional, so it does not always need to be set.
      Specified by:
      getFrom in interface StanzaView
      Returns:
      who the stanza is being sent from, or null if the value has not been set.
    • getLanguage

      public final 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 XmlLangElement
      Returns:
      the xml:lang of this XML element, or null.
    • getError

      public final StanzaError getError()
      Description copied from interface: StanzaView
      Returns the error associated with this packet, or null if there are no errors.
      Specified by:
      getError in interface StanzaView
      Returns:
      the error sub-packet or null if there isn't an error.
    • getExtension

      public final XmlElement getExtension(QName qname)
      Specified by:
      getExtension in interface StanzaView
    • getExtensions

      public final List<XmlElement> getExtensions()
      Description copied from interface: StanzaView
      Returns a list of all extension elements of this stanza.
      Specified by:
      getExtensions in interface StanzaView
      Returns:
      a list of all extension elements of this stanza.
    • getExtensions

      public final List<XmlElement> getExtensions(QName qname)
      Specified by:
      getExtensions in interface StanzaView
    • getExtensions

      public final <E extends ExtensionElement> List<E> getExtensions(Class<E> extensionElementClass)
      Description copied from interface: StanzaView
      Return all extension elements of the given type. Returns the empty list if there a none.
      Specified by:
      getExtensions in interface StanzaView
      Type Parameters:
      E - the type of extension elements.
      Parameters:
      extensionElementClass - the class of the type of extension elements.
      Returns:
      a list of extension elements of that type, which may be empty.
    • willBuildStanzaWithId

      public final boolean willBuildStanzaWithId()
    • throwIfNoStanzaId

      public final void throwIfNoStanzaId()
    • addStanzaSpecificAttributes

      protected abstract void addStanzaSpecificAttributes(ToStringUtil.Builder builder)
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • buildMessage

      public static MessageBuilder buildMessage()
    • buildMessage

      public static MessageBuilder buildMessage(String stanzaId)
    • buildMessageFrom

      public static MessageBuilder buildMessageFrom(Message message, String stanzaId)
    • buildMessageFrom

      public static MessageBuilder buildMessageFrom(Message message, StanzaIdSource stanzaIdSource)
    • buildPresence

      public static PresenceBuilder buildPresence()
    • buildPresence

      public static PresenceBuilder buildPresence(String stanzaId)
    • buildPresenceFrom

      public static PresenceBuilder buildPresenceFrom(Presence presence, String stanzaId)
    • buildPresenceFrom

      public static PresenceBuilder buildPresenceFrom(Presence presence, StanzaIdSource stanzaIdSource)
    • buildIqData

      public static IqData buildIqData(String stanzaId)
    • buildResponse

      public static <SB extends StanzaBuilder<?>> SB buildResponse(StanzaView request, Function<String,SB> builderFromStanzaId)