本文整理匯總了Java中org.jivesoftware.smack.util.StringUtils.requireNotNullOrEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.requireNotNullOrEmpty方法的具體用法?Java StringUtils.requireNotNullOrEmpty怎麽用?Java StringUtils.requireNotNullOrEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.requireNotNullOrEmpty方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeNickname
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Changes the occupant's nickname to a new nickname within the room. Each room occupant
* will receive two presence packets. One of type "unavailable" for the old nickname and one
* indicating availability for the new nickname. The unavailable presence will contain the new
* nickname and an appropriate status code (namely 303) as extended presence information. The
* status code 303 indicates that the occupant is changing his/her nickname.
*
* @param nickname the new nickname within the room.
* @throws XMPPErrorException if the new nickname is already in use by another occupant.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public void changeNickname(String nickname) throws NoResponseException, XMPPErrorException, NotConnectedException {
StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
// Check that we already have joined the room before attempting to change the
// nickname.
if (!joined) {
throw new IllegalStateException("Must be logged into the room to change nickname.");
}
// We change the nickname by sending a presence packet where the "to"
// field is in the form "[email protected]/nickname"
// We don't have to signal the MUC support again
Presence joinPresence = new Presence(Presence.Type.available);
joinPresence.setTo(room + "/" + nickname);
// Wait for a presence packet back from the server.
StanzaFilter responseFilter =
new AndFilter(
FromMatchesFilter.createFull(room + "/" + nickname),
new StanzaTypeFilter(Presence.class));
PacketCollector response = connection.createPacketCollectorAndSend(responseFilter, joinPresence);
// Wait up to a certain number of seconds for a reply. If there is a negative reply, an
// exception will be thrown
response.nextResultOrThrow();
this.nickname = nickname;
}
示例2: changeAvailabilityStatus
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Changes the occupant's availability status within the room. The presence type
* will remain available but with a new status that describes the presence update and
* a new presence mode (e.g. Extended away).
*
* @param status a text message describing the presence update.
* @param mode the mode type for the presence update.
* @throws NotConnectedException
*/
public void changeAvailabilityStatus(String status, Presence.Mode mode) throws NotConnectedException {
StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
// Check that we already have joined the room before attempting to change the
// availability status.
if (!joined) {
throw new IllegalStateException(
"Must be logged into the room to change the " + "availability status.");
}
// We change the availability status by sending a presence packet to the room with the
// new presence status and mode
Presence joinPresence = new Presence(Presence.Type.available);
joinPresence.setStatus(status);
joinPresence.setMode(mode);
joinPresence.setTo(room + "/" + nickname);
// Send join packet.
connection.sendStanza(joinPresence);
}
示例3: login
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Login with the given username (authorization identity). You may omit the password if a callback handler is used.
* If resource is null, then the server will generate one.
*
* @param username
* @param password
* @param resource
* @throws XMPPException
* @throws SmackException
* @throws IOException
* @see #login
*/
public synchronized void login(CharSequence username, String password, String resource) throws XMPPException,
SmackException, IOException {
if (!config.allowNullOrEmptyUsername) {
StringUtils.requireNotNullOrEmpty(username, "Username must not be null or empty");
}
throwNotConnectedExceptionIfAppropriate();
throwAlreadyLoggedInExceptionIfAppropriate();
usedUsername = username != null ? username.toString() : null;
usedPassword = password;
usedResource = resource;
loginNonAnonymously(usedUsername, usedPassword, usedResource);
}
示例4: Version
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new Version object with given details.
*
* @param name The natural-language name of the software. This element is REQUIRED.
* @param version The specific version of the software. This element is REQUIRED.
* @param os The operating system of the queried entity. This element is OPTIONAL.
*/
public Version(String name, String version, String os) {
super(ELEMENT, NAMESPACE);
this.setType(IQ.Type.result);
this.name = StringUtils.requireNotNullOrEmpty(name, "name must not be null");
this.version = StringUtils.requireNotNullOrEmpty(version, "version must not be null");
this.os = os;
}
示例5: AuthMechanism
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
public AuthMechanism(String mechanism, String authenticationText) {
this.mechanism = Objects.requireNonNull(mechanism, "SASL mechanism shouldn't be null.");
this.authenticationText = StringUtils.requireNotNullOrEmpty(authenticationText,
"SASL authenticationText must not be null or empty (RFC6120 6.4.2)");
}
示例6: enter
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Enter a room, as described in XEP-45 7.2.
*
* @param nickname
* @param password
* @param history
* @param timeout
* @return the returned presence by the service after the client send the initial presence in order to enter the room.
* @throws NotConnectedException
* @throws NoResponseException
* @throws XMPPErrorException
* @see <a href="http://xmpp.org/extensions/xep-0045.html#enter">XEP-45 7.2 Entering a Room</a>
*/
private Presence enter(String nickname, String password, DiscussionHistory history,
long timeout) throws NotConnectedException, NoResponseException,
XMPPErrorException {
StringUtils.requireNotNullOrEmpty(nickname, "Nickname must not be null or blank.");
// We enter a room by sending a presence packet where the "to"
// field is in the form "[email protected]/nickname"
Presence joinPresence = new Presence(Presence.Type.available);
joinPresence.setTo(room + "/" + nickname);
// Indicate the the client supports MUC
MUCInitialPresence mucInitialPresence = new MUCInitialPresence();
if (password != null) {
mucInitialPresence.setPassword(password);
}
if (history != null) {
mucInitialPresence.setHistory(history.getMUCHistory());
}
joinPresence.addExtension(mucInitialPresence);
// Wait for a presence packet back from the server.
StanzaFilter responseFilter = new AndFilter(FromMatchesFilter.createFull(room + "/"
+ nickname), new StanzaTypeFilter(Presence.class));
// Setup the messageListeners and presenceListeners *before* the join presence is send.
connection.addSyncStanzaListener(messageListener, fromRoomGroupchatFilter);
connection.addSyncStanzaListener(presenceListener, new AndFilter(fromRoomFilter,
StanzaTypeFilter.PRESENCE));
connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter,
MessageWithSubjectFilter.INSTANCE));
connection.addSyncStanzaListener(declinesListener, new AndFilter(new StanzaExtensionFilter(MUCUser.ELEMENT,
MUCUser.NAMESPACE), new NotFilter(MessageTypeFilter.ERROR)));
connection.addPacketInterceptor(presenceInterceptor, new AndFilter(new ToFilter(room),
StanzaTypeFilter.PRESENCE));
messageCollector = connection.createPacketCollector(fromRoomGroupchatFilter);
Presence presence;
try {
presence = connection.createPacketCollectorAndSend(responseFilter, joinPresence).nextResultOrThrow(timeout);
}
catch (NoResponseException | XMPPErrorException e) {
// Ensure that all callbacks are removed if there is an exception
removeConnectionCallbacks();
throw e;
}
this.nickname = nickname;
joined = true;
// Update the list of joined rooms
multiUserChatManager.addJoinedRoom(room);
return presence;
}
示例7: PacketExtensionFilter
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new stanza(/packet) extension filter. Packets will pass the filter if
* they have a stanza(/packet) extension that matches the specified element name
* and namespace.
*
* @param elementName the XML element name of the stanza(/packet) extension.
* @param namespace the XML namespace of the stanza(/packet) extension.
*/
public PacketExtensionFilter(String elementName, String namespace) {
StringUtils.requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
this.elementName = elementName;
this.namespace = namespace;
}
示例8: StanzaExtensionFilter
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new stanza extension filter. Stanzas will pass the filter if
* they have a stanza extension that matches the specified element name
* and namespace.
*
* @param elementName the XML element name of the stanza extension.
* @param namespace the XML namespace of the stanza extension.
*/
public StanzaExtensionFilter(String elementName, String namespace) {
StringUtils.requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
this.elementName = elementName;
this.namespace = namespace;
}
示例9: Identity
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new identity for an XMPP entity.
* 'category' and 'type' are required by
* <a href="http://xmpp.org/extensions/xep-0030.html#schemas">XEP-30 XML Schemas</a>
*
* @param category the entity's category (required as per XEP-30).
* @param type the entity's type (required as per XEP-30).
* @param name the entity's name.
* @param lang the entity's lang.
*/
public Identity(String category, String type, String name, String lang) {
this.category = StringUtils.requireNotNullOrEmpty(category, "category cannot be null");
this.type = StringUtils.requireNotNullOrEmpty(type, "type cannot be null");
this.key = XmppStringUtils.generateKey(category, type);
this.name = name;
this.lang = lang;
}
示例10: StanzaIdFilter
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new stanza ID filter using the specified stanza ID.
*
* @param stanzaID the stanza ID to filter for.
*/
public StanzaIdFilter(String stanzaID) {
this.stanzaId = StringUtils.requireNotNullOrEmpty(stanzaID, "Stanza ID must not be null or empty.");
}
示例11: ThreadFilter
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new thread filter using the specified thread value.
*
* @param thread the thread value to filter for.
*/
public ThreadFilter(String thread) {
StringUtils.requireNotNullOrEmpty(thread, "Thread must not be null or empty.");
this.thread = thread;
}
示例12: PacketIDFilter
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new stanza(/packet) ID filter using the specified stanza(/packet) ID.
*
* @param packetID the stanza(/packet) ID to filter for.
* @deprecated use {@link StanzaIdFilter#StanzaIdFilter(Stanza)} instead.
*/
@Deprecated
public PacketIDFilter(String packetID) {
StringUtils.requireNotNullOrEmpty(packetID, "Packet ID must not be null or empty.");
this.packetID = packetID;
}
示例13: getPrivacyList
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Answer the privacy list items under listName with the allowed and blocked permissions.
*
* @param listName the name of the list to get the allowed and blocked permissions.
* @return a privacy list under the list listName.
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public PrivacyList getPrivacyList(String listName) throws NoResponseException, XMPPErrorException, NotConnectedException {
listName = StringUtils.requireNotNullOrEmpty(listName, "List name must not be null");
return new PrivacyList(false, false, listName, getPrivacyListItems(listName));
}
示例14: Feature
import org.jivesoftware.smack.util.StringUtils; //導入方法依賴的package包/類
/**
* Creates a new feature offered by an XMPP entity or item.
*
* @param variable the feature's variable.
*/
public Feature(String variable) {
this.variable = StringUtils.requireNotNullOrEmpty(variable, "variable cannot be null");
}