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
ConstructorsModifierConstructorDescriptionprotectedStanzaBuilder(String stanzaId) protectedStanzaBuilder(StanzaIdSource stanzaIdSource) protectedStanzaBuilder(StanzaBuilder<?> other) protectedStanzaBuilder(Stanza message, String stanzaId) protectedStanzaBuilder(Stanza message, StanzaIdSource stanzaIdSource) -
Method Summary
Modifier and TypeMethodDescriptionfinal BaddExtension(XmlElement extensionElement) final BaddExtensions(Collection<? extends XmlElement> extensionElements) final BaddOptExtensions(Collection<? extends XmlElement> extensionElements) protected abstract voidabstract Stanzabuild()static IqDatabuildIqData(String stanzaId) static MessageBuilderstatic MessageBuilderbuildMessage(String stanzaId) static MessageBuilderbuildMessageFrom(Message message, String stanzaId) static MessageBuilderbuildMessageFrom(Message message, StanzaIdSource stanzaIdSource) static PresenceBuilderstatic PresenceBuilderbuildPresence(String stanzaId) static PresenceBuilderbuildPresenceFrom(Presence presence, String stanzaId) static PresenceBuilderbuildPresenceFrom(Presence presence, StanzaIdSource stanzaIdSource) static <SB extends StanzaBuilder<?>>
SBbuildResponse(StanzaView request, Function<String, SB> builderFromStanzaId) final Bfrom(CharSequence from) Sets who the stanza is being sent "from".final BSets who the stanza is being sent "from".final StanzaErrorgetError()Returns the error associated with this packet, ornullif there are no errors.final XmlElementgetExtension(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 JidgetFrom()Returns who the stanza is being sent "from" ornullif the value is not set.final StringReturns the xml:lang of this XML element, or null if one has not been set.final StringReturns the unique ID of the stanza.abstract BgetThis()final JidgetTo()Returns who the stanza is being sent "to", ornullif the value is not set.final BoverrideExtension(XmlElement extensionElement) final BremoveExtension(String elementName, String namespace) final BremoveExtension(ExtensionElement extension) final BsetError(StanzaError stanzaError) Sets the error for this stanza.final BsetLanguage(String language) Sets the xml:lang for this stanza.final voidfinal Bto(CharSequence to) Set the recipient address of the stanza.final BSets who the stanza is being sent "to".final StringtoString()final booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:StanzaViewReturns the unique ID of the stanza. The returned value could benull.- Specified by:
getStanzaIdin interfaceStanzaView- Returns:
- the packet's unique ID or
nullif the id is not available.
-
getTo
Description copied from interface:StanzaViewReturns who the stanza is being sent "to", ornullif 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:
getToin interfaceStanzaView- Returns:
- who the stanza is being sent to, or
nullif the value has not been set.
-
getFrom
Description copied from interface:StanzaViewReturns who the stanza is being sent "from" ornullif 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:
getFromin interfaceStanzaView- Returns:
- who the stanza is being sent from, or
nullif the value has not been set.
-
getLanguage
Description copied from interface:XmlLangElementReturns the xml:lang of this XML element, or null if one has not been set.- Specified by:
getLanguagein interfaceXmlLangElement- Returns:
- the xml:lang of this XML element, or null.
-
getError
Description copied from interface:StanzaViewReturns the error associated with this packet, ornullif there are no errors.- Specified by:
getErrorin interfaceStanzaView- Returns:
- the error sub-packet or
nullif there isn't an error.
-
getExtension
- Specified by:
getExtensionin interfaceStanzaView
-
getExtensions
Description copied from interface:StanzaViewReturns a list of all extension elements of this stanza.- Specified by:
getExtensionsin interfaceStanzaView- Returns:
- a list of all extension elements of this stanza.
-
getExtensions
- Specified by:
getExtensionsin interfaceStanzaView
-
getExtensions
Description copied from interface:StanzaViewReturn all extension elements of the given type. Returns the empty list if there a none.- Specified by:
getExtensionsin 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)
-