Package org.jivesoftware.smack.packet
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 Summary
ModifierConstructorDescriptionprotected
StanzaBuilder
(String stanzaId) protected
StanzaBuilder
(StanzaIdSource stanzaIdSource) protected
StanzaBuilder
(StanzaBuilder<?> other) protected
StanzaBuilder
(Stanza message, String stanzaId) protected
StanzaBuilder
(Stanza message, StanzaIdSource stanzaIdSource) -
Method Summary
Modifier and TypeMethodDescriptionfinal B
addExtension
(XmlElement extensionElement) final B
addExtensions
(Collection<? extends XmlElement> extensionElements) final B
addOptExtensions
(Collection<? extends XmlElement> extensionElements) protected abstract void
abstract Stanza
build()
static IqData
buildIqData
(String stanzaId) static MessageBuilder
static MessageBuilder
buildMessage
(String stanzaId) static MessageBuilder
buildMessageFrom
(Message message, String stanzaId) static MessageBuilder
buildMessageFrom
(Message message, StanzaIdSource stanzaIdSource) static PresenceBuilder
static PresenceBuilder
buildPresence
(String stanzaId) static PresenceBuilder
buildPresenceFrom
(Presence presence, String stanzaId) static PresenceBuilder
buildPresenceFrom
(Presence presence, StanzaIdSource stanzaIdSource) static <SB extends StanzaBuilder<?>>
SBbuildResponse
(StanzaView request, Function<String, SB> builderFromStanzaId) final B
from
(CharSequence from) Sets who the stanza is being sent "from".final B
Sets who the stanza is being sent "from".final StanzaError
getError()
Returns the error associated with this packet, ornull
if there are no errors.final XmlElement
getExtension
(QName qname) final List<XmlElement>
Returns a list of all extension elements of this stanza.final <E extends ExtensionElement>
List<E>getExtensions
(Class<E> extensionElementClass) Return all extension elements of the given type.final List<XmlElement>
getExtensions
(QName qname) final Jid
getFrom()
Returns who the stanza is being sent "from" ornull
if the value is not set.final String
Returns the xml:lang of this XML element, or null if one has not been set.final String
Returns the unique ID of the stanza.abstract B
getThis()
final Jid
getTo()
Returns who the stanza is being sent "to", ornull
if the value is not set.final B
overrideExtension
(XmlElement extensionElement) final B
removeExtension
(String elementName, String namespace) final B
removeExtension
(ExtensionElement extension) final B
setError
(StanzaError stanzaError) Sets the error for this stanza.final B
setLanguage
(String language) Sets the xml:lang for this stanza.final void
final B
to
(CharSequence to) Set the recipient address of the stanza.final B
Sets who the stanza is being sent "to".final String
toString()
final boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jivesoftware.smack.packet.StanzaView
getExtension, hasExtension, hasExtension, hasExtension
-
Constructor Details
-
StanzaBuilder
-
StanzaBuilder
-
StanzaBuilder
-
StanzaBuilder
-
StanzaBuilder
-
-
Method Details
-
to
Set the recipient address of the stanza.- Parameters:
to
- whom the stanza is being sent.- Returns:
- a reference to this builder.
- Throws:
XmppStringprepException
- if the provided character sequence is not a valid XMPP address.- See Also:
-
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
Sets who the stanza is being sent "from".- Parameters:
from
- who the stanza is being sent from.- Returns:
- a reference to this builder.
- Throws:
XmppStringprepException
- if the provided character sequence is not a valid XMPP address.- See Also:
-
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
Sets the error for this stanza.- Parameters:
stanzaError
- the error to associate with this stanza.- Returns:
- a reference to this builder.
-
setLanguage
Sets the xml:lang for this stanza.- Parameters:
language
- the xml:lang of this stanza.- Returns:
- a reference to this builder.
-
addExtension
-
addOptExtensions
-
addExtensions
-
overrideExtension
-
removeExtension
-
removeExtension
-
build
-
getThis
-
getStanzaId
Description copied from interface:StanzaView
Returns the unique ID of the stanza. The returned value could benull
.- Specified by:
getStanzaId
in interfaceStanzaView
- Returns:
- the packet's unique ID or
null
if the id is not available.
-
getTo
Description copied from interface:StanzaView
Returns who the stanza is being sent "to", ornull
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 interfaceStanzaView
- Returns:
- who the stanza is being sent to, or
null
if the value has not been set.
-
getFrom
Description copied from interface:StanzaView
Returns who the stanza is being sent "from" ornull
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 interfaceStanzaView
- Returns:
- who the stanza is being sent from, or
null
if the value has not been set.
-
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 interfaceXmlLangElement
- Returns:
- the xml:lang of this XML element, or null.
-
getError
Description copied from interface:StanzaView
Returns the error associated with this packet, ornull
if there are no errors.- Specified by:
getError
in interfaceStanzaView
- Returns:
- the error sub-packet or
null
if there isn't an error.
-
getExtension
- Specified by:
getExtension
in interfaceStanzaView
-
getExtensions
Description copied from interface:StanzaView
Returns a list of all extension elements of this stanza.- Specified by:
getExtensions
in interfaceStanzaView
- Returns:
- a list of all extension elements of this stanza.
-
getExtensions
- Specified by:
getExtensions
in interfaceStanzaView
-
getExtensions
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 interfaceStanzaView
- 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
-
throwIfNoStanzaId
-
addStanzaSpecificAttributes
-
toString
-
buildMessage
-
buildMessage
-
buildMessageFrom
-
buildMessageFrom
-
buildPresence
-
buildPresence
-
buildPresenceFrom
-
buildPresenceFrom
-
buildIqData
-
buildResponse
public static <SB extends StanzaBuilder<?>> SB buildResponse(StanzaView request, Function<String, SB> builderFromStanzaId)
-