mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-25 21:42:07 +01:00
Return Collections (or sublcasses) instead of Iterators
This allows us to exploid Java 8 streams and Java 5 for-each loops. The returned Collections are usually unmodifiable. We decided against returning Iterable because this would mean determining the size in O(n) compared to Collection.size() which is often faster (e.g. O(1)).
This commit is contained in:
parent
6ea1d65e73
commit
4cff008708
31 changed files with 219 additions and 282 deletions
|
@ -22,7 +22,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -583,17 +582,18 @@ public class Roster {
|
||||||
* updates.
|
* updates.
|
||||||
*
|
*
|
||||||
* @param user a XMPP ID, e.g. jdoe@example.com.
|
* @param user a XMPP ID, e.g. jdoe@example.com.
|
||||||
* @return an iterator (of Presence objects) for all the user's current presences,
|
* @return an Collection (of Presence objects) for all the user's current presences,
|
||||||
* or an unavailable presence if the user is offline or if no presence information
|
* or an unavailable presence if the user is offline or if no presence information
|
||||||
* is available.
|
* is available.
|
||||||
*/
|
*/
|
||||||
public Iterator<Presence> getPresences(String user) {
|
public Collection<Presence> getPresences(String user) {
|
||||||
|
Collection<Presence> res;
|
||||||
String key = getPresenceMapKey(user);
|
String key = getPresenceMapKey(user);
|
||||||
Map<String, Presence> userPresences = presenceMap.get(key);
|
Map<String, Presence> userPresences = presenceMap.get(key);
|
||||||
if (userPresences == null) {
|
if (userPresences == null) {
|
||||||
Presence presence = new Presence(Presence.Type.unavailable);
|
Presence presence = new Presence(Presence.Type.unavailable);
|
||||||
presence.setFrom(user);
|
presence.setFrom(user);
|
||||||
return Arrays.asList(presence).iterator();
|
res = Arrays.asList(presence);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Collection<Presence> answer = new ArrayList<Presence>();
|
Collection<Presence> answer = new ArrayList<Presence>();
|
||||||
|
@ -603,14 +603,15 @@ public class Roster {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!answer.isEmpty()) {
|
if (!answer.isEmpty()) {
|
||||||
return answer.iterator();
|
res = answer;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Presence presence = new Presence(Presence.Type.unavailable);
|
Presence presence = new Presence(Presence.Type.unavailable);
|
||||||
presence.setFrom(user);
|
presence.setFrom(user);
|
||||||
return Arrays.asList(presence).iterator();
|
res = Arrays.asList(presence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Collections.unmodifiableCollection(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -190,11 +190,11 @@ public class XMPPError {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the error extensions attached to the xmppError.
|
* Returns a List of the error extensions attached to the xmppError.
|
||||||
* An application MAY provide application-specific error information by including a
|
* An application MAY provide application-specific error information by including a
|
||||||
* properly-namespaced child in the error element.
|
* properly-namespaced child in the error element.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the error extensions.
|
* @return a List of the error extensions.
|
||||||
*/
|
*/
|
||||||
public synchronized List<PacketExtension> getExtensions() {
|
public synchronized List<PacketExtension> getExtensions() {
|
||||||
if (applicationExtensions == null) {
|
if (applicationExtensions == null) {
|
||||||
|
|
|
@ -93,13 +93,13 @@ information concerning a node named "http://jabber.org/protocol/muc#rooms": <br>
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
|
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
|
||||||
<font color="#0000FF">"http://jabber.org/protocol/muc#rooms"</font>,
|
<font color="#0000FF">"http://jabber.org/protocol/muc#rooms"</font>,
|
||||||
new NodeInformationProvider() {
|
new NodeInformationProvider() {
|
||||||
public Iterator getNodeItems() {
|
public List getNodeItems() {
|
||||||
ArrayList answer = new ArrayList();
|
ArrayList answer = new ArrayList();
|
||||||
Iterator rooms = MultiUserChat.getJoinedRooms(connection);
|
Iterator rooms = MultiUserChat.getJoinedRooms(connection);
|
||||||
while (rooms.hasNext()) {
|
while (rooms.hasNext()) {
|
||||||
answer.add(new DiscoverItems.Item((String)rooms.next()));
|
answer.add(new DiscoverItems.Item((String)rooms.next()));
|
||||||
}
|
}
|
||||||
return answer.iterator();
|
return answer;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -80,12 +80,12 @@ public class AMPExtension implements PacketExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the rules in the packet.
|
* Returns a Collection of the rules in the packet.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the rules in the packet.
|
* @return a Collection of the rules in the packet.
|
||||||
*/
|
*/
|
||||||
public Iterator<Rule> getRules() {
|
public Collection<Rule> getRules() {
|
||||||
return Collections.unmodifiableList(new ArrayList<Rule>(rules)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Rule>(rules));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,8 +168,8 @@ public class AMPExtension implements PacketExtension {
|
||||||
buf.append(">");
|
buf.append(">");
|
||||||
|
|
||||||
// Loop through all the rules and append them to the string buffer
|
// Loop through all the rules and append them to the string buffer
|
||||||
for (Iterator<Rule> i = getRules(); i.hasNext();) {
|
for (Rule rule : getRules()) {
|
||||||
buf.append(i.next().toXML());
|
buf.append(rule.toXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.append("</").append(getElementName()).append(">");
|
buf.append("</").append(getElementName()).append(">");
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,9 +166,7 @@ public class Bookmarks implements PrivateData {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<storage xmlns=\"storage:bookmarks\">");
|
buf.append("<storage xmlns=\"storage:bookmarks\">");
|
||||||
|
|
||||||
final Iterator<BookmarkedURL> urls = getBookmarkedURLS().iterator();
|
for (BookmarkedURL urlStorage : getBookmarkedURLS()) {
|
||||||
while (urls.hasNext()) {
|
|
||||||
BookmarkedURL urlStorage = urls.next();
|
|
||||||
if(urlStorage.isShared()) {
|
if(urlStorage.isShared()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -182,9 +179,7 @@ public class Bookmarks implements PrivateData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add Conference additions
|
// Add Conference additions
|
||||||
final Iterator<BookmarkedConference> conferences = getBookmarkedConferences().iterator();
|
for (BookmarkedConference conference : getBookmarkedConferences()) {
|
||||||
while (conferences.hasNext()) {
|
|
||||||
BookmarkedConference conference = conferences.next();
|
|
||||||
if(conference.isShared()) {
|
if(conference.isShared()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -528,12 +527,10 @@ public class EntityCapsManager extends Manager {
|
||||||
*/
|
*/
|
||||||
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
|
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
|
||||||
List<FormField> foundFormTypes = new LinkedList<FormField>();
|
List<FormField> foundFormTypes = new LinkedList<FormField>();
|
||||||
for (Iterator<PacketExtension> i = info.getExtensions().iterator(); i.hasNext();) {
|
for (PacketExtension pe : info.getExtensions()) {
|
||||||
PacketExtension pe = i.next();
|
|
||||||
if (pe.getNamespace().equals(Form.NAMESPACE)) {
|
if (pe.getNamespace().equals(Form.NAMESPACE)) {
|
||||||
DataForm df = (DataForm) pe;
|
DataForm df = (DataForm) pe;
|
||||||
for (Iterator<FormField> it = df.getFields(); it.hasNext();) {
|
for (FormField f : df.getFields()) {
|
||||||
FormField f = it.next();
|
|
||||||
if (f.getVariable().equals("FORM_TYPE")) {
|
if (f.getVariable().equals("FORM_TYPE")) {
|
||||||
for (FormField fft : foundFormTypes) {
|
for (FormField fft : foundFormTypes) {
|
||||||
if (f.equals(fft))
|
if (f.equals(fft))
|
||||||
|
@ -583,8 +580,7 @@ public class EntityCapsManager extends Manager {
|
||||||
|
|
||||||
// 3. For each identity, append the 'category/type/lang/name' to S,
|
// 3. For each identity, append the 'category/type/lang/name' to S,
|
||||||
// followed by the '<' character.
|
// followed by the '<' character.
|
||||||
for (Iterator<DiscoverInfo.Identity> it = sortedIdentities.iterator(); it.hasNext();) {
|
for (DiscoverInfo.Identity identity : sortedIdentities) {
|
||||||
DiscoverInfo.Identity identity = it.next();
|
|
||||||
sb.append(identity.getCategory());
|
sb.append(identity.getCategory());
|
||||||
sb.append("/");
|
sb.append("/");
|
||||||
sb.append(identity.getType());
|
sb.append(identity.getType());
|
||||||
|
@ -623,8 +619,7 @@ public class EntityCapsManager extends Manager {
|
||||||
|
|
||||||
FormField ft = null;
|
FormField ft = null;
|
||||||
|
|
||||||
for (Iterator<FormField> i = extendedInfo.getFields(); i.hasNext();) {
|
for (FormField f : extendedInfo.getFields()) {
|
||||||
FormField f = i.next();
|
|
||||||
if (!f.getVariable().equals("FORM_TYPE")) {
|
if (!f.getVariable().equals("FORM_TYPE")) {
|
||||||
fs.add(f);
|
fs.add(f);
|
||||||
} else {
|
} else {
|
||||||
|
@ -664,10 +659,10 @@ public class EntityCapsManager extends Manager {
|
||||||
return Base64.encodeBytes(digest);
|
return Base64.encodeBytes(digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void formFieldValuesToCaps(Iterator<String> i, StringBuilder sb) {
|
private static void formFieldValuesToCaps(List<String> i, StringBuilder sb) {
|
||||||
SortedSet<String> fvs = new TreeSet<String>();
|
SortedSet<String> fvs = new TreeSet<String>();
|
||||||
while (i.hasNext()) {
|
for (String s : i) {
|
||||||
fvs.add(i.next());
|
fvs.add(s);
|
||||||
}
|
}
|
||||||
for (String fv : fvs) {
|
for (String fv : fvs) {
|
||||||
sb.append(fv);
|
sb.append(fv);
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -314,8 +313,8 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
|
|
||||||
// Add the registered features to the response
|
// Add the registered features to the response
|
||||||
synchronized (features) {
|
synchronized (features) {
|
||||||
for (Iterator<String> it = getFeatures(); it.hasNext();) {
|
for (String feature : getFeatures()) {
|
||||||
response.addFeature(it.next());
|
response.addFeature(feature);
|
||||||
}
|
}
|
||||||
response.addExtension(extendedInfo);
|
response.addExtension(extendedInfo);
|
||||||
}
|
}
|
||||||
|
@ -373,11 +372,11 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
/**
|
/**
|
||||||
* Returns the supported features by this XMPP entity.
|
* Returns the supported features by this XMPP entity.
|
||||||
*
|
*
|
||||||
* @return an Iterator on the supported features by this XMPP entity.
|
* @return a List of the supported features by this XMPP entity.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getFeatures() {
|
public List<String> getFeatures() {
|
||||||
synchronized (features) {
|
synchronized (features) {
|
||||||
return Collections.unmodifiableList(new ArrayList<String>(features)).iterator();
|
return Collections.unmodifiableList(new ArrayList<String>(features));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -280,24 +279,21 @@ public class FileTransferNegotiator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private FormField getStreamMethodField(DataForm form) {
|
private FormField getStreamMethodField(DataForm form) {
|
||||||
FormField field = null;
|
for (FormField field : form.getFields()) {
|
||||||
for (Iterator<FormField> it = form.getFields(); it.hasNext();) {
|
|
||||||
field = it.next();
|
|
||||||
if (field.getVariable().equals(STREAM_DATA_FIELD_NAME)) {
|
if (field.getVariable().equals(STREAM_DATA_FIELD_NAME)) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
field = null;
|
|
||||||
}
|
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private StreamNegotiator getNegotiator(final FormField field)
|
private StreamNegotiator getNegotiator(final FormField field)
|
||||||
throws XMPPErrorException {
|
throws XMPPErrorException {
|
||||||
String variable;
|
String variable;
|
||||||
boolean isByteStream = false;
|
boolean isByteStream = false;
|
||||||
boolean isIBB = false;
|
boolean isIBB = false;
|
||||||
for (Iterator<FormField.Option> it = field.getOptions(); it.hasNext();) {
|
for (FormField.Option option : field.getOptions()) {
|
||||||
variable = it.next().getValue();
|
variable = option.getValue();
|
||||||
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
|
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
|
||||||
isByteStream = true;
|
isByteStream = true;
|
||||||
}
|
}
|
||||||
|
@ -425,11 +421,9 @@ public class FileTransferNegotiator {
|
||||||
|
|
||||||
private StreamNegotiator getOutgoingNegotiator(final FormField field)
|
private StreamNegotiator getOutgoingNegotiator(final FormField field)
|
||||||
throws XMPPErrorException {
|
throws XMPPErrorException {
|
||||||
String variable;
|
|
||||||
boolean isByteStream = false;
|
boolean isByteStream = false;
|
||||||
boolean isIBB = false;
|
boolean isIBB = false;
|
||||||
for (Iterator<String> it = field.getValues(); it.hasNext();) {
|
for (String variable : field.getValues()) {
|
||||||
variable = it.next();
|
|
||||||
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
|
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
|
||||||
isByteStream = true;
|
isByteStream = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smackx.iqprivate.packet;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of the PrivateData interface. Unless a PrivateDataProvider
|
* Default implementation of the PrivateData interface. Unless a PrivateDataProvider
|
||||||
|
@ -82,8 +82,7 @@ public class DefaultPrivateData implements PrivateData {
|
||||||
public String toXML() {
|
public String toXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">");
|
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">");
|
||||||
for (Iterator<String> i=getNames(); i.hasNext(); ) {
|
for (String name : getNames()) {
|
||||||
String name = i.next();
|
|
||||||
String value = getValue(name);
|
String value = getValue(name);
|
||||||
buf.append("<").append(name).append(">");
|
buf.append("<").append(name).append(">");
|
||||||
buf.append(value);
|
buf.append(value);
|
||||||
|
@ -94,16 +93,16 @@ public class DefaultPrivateData implements PrivateData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the names that can be used to get
|
* Returns a Set of the names that can be used to get
|
||||||
* values of the private data.
|
* values of the private data.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the names.
|
* @return a Set of the names.
|
||||||
*/
|
*/
|
||||||
public synchronized Iterator<String> getNames() {
|
public synchronized Set<String> getNames() {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
return Collections.<String>emptyList().iterator();
|
return Collections.<String>emptySet();
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableSet(map.keySet()).iterator();
|
return Collections.unmodifiableSet(map.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -129,9 +128,8 @@ public class MultiUserChat {
|
||||||
XMPPConnection connection = weakRefConnection.get();
|
XMPPConnection connection = weakRefConnection.get();
|
||||||
if (connection == null) return new LinkedList<DiscoverItems.Item>();
|
if (connection == null) return new LinkedList<DiscoverItems.Item>();
|
||||||
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
|
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
|
||||||
Iterator<String> rooms=MultiUserChat.getJoinedRooms(connection);
|
for (String room : MultiUserChat.getJoinedRooms(connection)) {
|
||||||
while (rooms.hasNext()) {
|
answer.add(new DiscoverItems.Item(room));
|
||||||
answer.add(new DiscoverItems.Item(rooms.next()));
|
|
||||||
}
|
}
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
@ -191,34 +189,34 @@ public class MultiUserChat {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator on the rooms where the user has joined using a given connection.
|
* Returns a List of the rooms where the user has joined using a given connection.
|
||||||
* The Iterator will contain Strings where each String represents a room
|
* The Iterator will contain Strings where each String represents a room
|
||||||
* (e.g. room@muc.jabber.org).
|
* (e.g. room@muc.jabber.org).
|
||||||
*
|
*
|
||||||
* @param connection the connection used to join the rooms.
|
* @param connection the connection used to join the rooms.
|
||||||
* @return an Iterator on the rooms where the user has joined using a given connection.
|
* @return a List of the rooms where the user has joined using a given connection.
|
||||||
*/
|
*/
|
||||||
private static Iterator<String> getJoinedRooms(XMPPConnection connection) {
|
private static List<String> getJoinedRooms(XMPPConnection connection) {
|
||||||
List<String> rooms = joinedRooms.get(connection);
|
List<String> rooms = joinedRooms.get(connection);
|
||||||
if (rooms != null) {
|
if (rooms != null) {
|
||||||
return rooms.iterator();
|
return rooms;
|
||||||
}
|
}
|
||||||
// Return an iterator on an empty collection (i.e. the user never joined a room)
|
// Return an empty collection (i.e. the user never joined a room)
|
||||||
return new ArrayList<String>().iterator();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator on the rooms where the requested user has joined. The Iterator will
|
* Returns a List of the rooms where the requested user has joined. The Iterator will
|
||||||
* contain Strings where each String represents a room (e.g. room@muc.jabber.org).
|
* contain Strings where each String represents a room (e.g. room@muc.jabber.org).
|
||||||
*
|
*
|
||||||
* @param connection the connection to use to perform the service discovery.
|
* @param connection the connection to use to perform the service discovery.
|
||||||
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
||||||
* @return an Iterator on the rooms where the requested user has joined.
|
* @return a List of the rooms where the requested user has joined.
|
||||||
* @throws XMPPErrorException
|
* @throws XMPPErrorException
|
||||||
* @throws NoResponseException
|
* @throws NoResponseException
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user)
|
public static List<String> getJoinedRooms(XMPPConnection connection, String user)
|
||||||
throws NoResponseException, XMPPErrorException, NotConnectedException {
|
throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
ArrayList<String> answer = new ArrayList<String>();
|
ArrayList<String> answer = new ArrayList<String>();
|
||||||
// Send the disco packet to the user
|
// Send the disco packet to the user
|
||||||
|
@ -228,7 +226,7 @@ public class MultiUserChat {
|
||||||
for (DiscoverItems.Item item : result.getItems()) {
|
for (DiscoverItems.Item item : result.getItems()) {
|
||||||
answer.add(item.getEntityID());
|
answer.add(item.getEntityID());
|
||||||
}
|
}
|
||||||
return answer.iterator();
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1463,11 +1461,10 @@ public class MultiUserChat {
|
||||||
* Note: this value will only be accurate after joining the group chat, and may
|
* Note: this value will only be accurate after joining the group chat, and may
|
||||||
* fluctuate over time.
|
* fluctuate over time.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the occupants in the group chat.
|
* @return a List of the occupants in the group chat.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getOccupants() {
|
public List<String> getOccupants() {
|
||||||
return Collections.unmodifiableList(new ArrayList<String>(occupantsMap.keySet()))
|
return Collections.unmodifiableList(new ArrayList<String>(occupantsMap.keySet()));
|
||||||
.iterator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1595,8 +1592,8 @@ public class MultiUserChat {
|
||||||
|
|
||||||
// Get the list of affiliates from the server's answer
|
// Get the list of affiliates from the server's answer
|
||||||
List<Affiliate> affiliates = new ArrayList<Affiliate>();
|
List<Affiliate> affiliates = new ArrayList<Affiliate>();
|
||||||
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
|
for (MUCAdmin.Item mucadminItem : answer.getItems()) {
|
||||||
affiliates.add(new Affiliate(it.next()));
|
affiliates.add(new Affiliate(mucadminItem));
|
||||||
}
|
}
|
||||||
return affiliates;
|
return affiliates;
|
||||||
}
|
}
|
||||||
|
@ -1646,8 +1643,8 @@ public class MultiUserChat {
|
||||||
MUCAdmin answer = (MUCAdmin) connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
|
MUCAdmin answer = (MUCAdmin) connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
|
||||||
// Get the list of participants from the server's answer
|
// Get the list of participants from the server's answer
|
||||||
List<Occupant> participants = new ArrayList<Occupant>();
|
List<Occupant> participants = new ArrayList<Occupant>();
|
||||||
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
|
for (MUCAdmin.Item mucadminItem : answer.getItems()) {
|
||||||
participants.add(new Occupant(it.next()));
|
participants.add(new Occupant(mucadminItem));
|
||||||
}
|
}
|
||||||
return participants;
|
return participants;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,14 +85,14 @@ public class RoomInfo {
|
||||||
Form form = Form.getFormFrom(info);
|
Form form = Form.getFormFrom(info);
|
||||||
if (form != null) {
|
if (form != null) {
|
||||||
FormField descField = form.getField("muc#roominfo_description");
|
FormField descField = form.getField("muc#roominfo_description");
|
||||||
this.description = ( descField == null || !(descField.getValues().hasNext()) )? "" : descField.getValues().next();
|
this.description = ( descField == null || descField.getValues().isEmpty() ) ? "" : descField.getValues().get(0);
|
||||||
|
|
||||||
FormField subjField = form.getField("muc#roominfo_subject");
|
FormField subjField = form.getField("muc#roominfo_subject");
|
||||||
this.subject = ( subjField == null || !(subjField.getValues().hasNext()) ) ? "" : subjField.getValues().next();
|
this.subject = ( subjField == null || subjField.getValues().isEmpty() ) ? "" : subjField.getValues().get(0);
|
||||||
|
|
||||||
FormField occCountField = form.getField("muc#roominfo_occupants");
|
FormField occCountField = form.getField("muc#roominfo_occupants");
|
||||||
this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues()
|
this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues()
|
||||||
.next());
|
.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.muc.packet;
|
package org.jivesoftware.smackx.muc.packet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
@ -36,15 +36,15 @@ public class MUCAdmin extends IQ {
|
||||||
private List<Item> items = new ArrayList<Item>();
|
private List<Item> items = new ArrayList<Item>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for item childs that holds information about roles, affiliation,
|
* Returns a Collection of item childs that holds information about roles, affiliation,
|
||||||
* jids and nicks.
|
* jids and nicks.
|
||||||
*
|
*
|
||||||
* @return an Iterator for item childs that holds information about roles, affiliation,
|
* @return a Collection of item childs that holds information about roles, affiliation,
|
||||||
* jids and nicks.
|
* jids and nicks.
|
||||||
*/
|
*/
|
||||||
public Iterator<Item> getItems() {
|
public Collection<Item> getItems() {
|
||||||
synchronized (items) {
|
synchronized (items) {
|
||||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Item>(items));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smackx.muc.packet;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,15 +36,15 @@ public class MUCOwner extends IQ {
|
||||||
private Destroy destroy;
|
private Destroy destroy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for item childs that holds information about affiliation,
|
* Returns a Collection of item childs that holds information about affiliation,
|
||||||
* jids and nicks.
|
* jids and nicks.
|
||||||
*
|
*
|
||||||
* @return an Iterator for item childs that holds information about affiliation,
|
* @return a Collection of item childs that holds information about affiliation,
|
||||||
* jids and nicks.
|
* jids and nicks.
|
||||||
*/
|
*/
|
||||||
public Iterator<Item> getItems() {
|
public Collection<Item> getItems() {
|
||||||
synchronized (items) {
|
synchronized (items) {
|
||||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Item>(items));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.jivesoftware.smackx.offline.packet.OfflineMessageRequest;
|
||||||
import org.jivesoftware.smackx.xdata.Form;
|
import org.jivesoftware.smackx.xdata.Form;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,49 +98,49 @@ public class OfflineMessageManager {
|
||||||
namespace);
|
namespace);
|
||||||
Form extendedInfo = Form.getFormFrom(info);
|
Form extendedInfo = Form.getFormFrom(info);
|
||||||
if (extendedInfo != null) {
|
if (extendedInfo != null) {
|
||||||
String value = extendedInfo.getField("number_of_messages").getValues().next();
|
String value = extendedInfo.getField("number_of_messages").getValues().get(0);
|
||||||
return Integer.parseInt(value);
|
return Integer.parseInt(value);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterator on <tt>OfflineMessageHeader</tt> that keep information about the
|
* Returns a List of <tt>OfflineMessageHeader</tt> that keep information about the
|
||||||
* offline message. The OfflineMessageHeader includes a stamp that could be used to retrieve
|
* offline message. The OfflineMessageHeader includes a stamp that could be used to retrieve
|
||||||
* the complete message or delete the specific message.
|
* the complete message or delete the specific message.
|
||||||
*
|
*
|
||||||
* @return an iterator on <tt>OfflineMessageHeader</tt> that keep information about the offline
|
* @return a List of <tt>OfflineMessageHeader</tt> that keep information about the offline
|
||||||
* message.
|
* message.
|
||||||
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
|
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
|
||||||
* not support offline message retrieval.
|
* not support offline message retrieval.
|
||||||
* @throws NoResponseException if there was no response from the server.
|
* @throws NoResponseException if there was no response from the server.
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
public Iterator<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
|
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
|
||||||
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
|
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
|
||||||
null, namespace);
|
null, namespace);
|
||||||
for (DiscoverItems.Item item : items.getItems()) {
|
for (DiscoverItems.Item item : items.getItems()) {
|
||||||
answer.add(new OfflineMessageHeader(item));
|
answer.add(new OfflineMessageHeader(item));
|
||||||
}
|
}
|
||||||
return answer.iterator();
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator with the offline <tt>Messages</tt> whose stamp matches the specified
|
* Returns a List of the offline <tt>Messages</tt> whose stamp matches the specified
|
||||||
* request. The request will include the list of stamps that uniquely identifies
|
* request. The request will include the list of stamps that uniquely identifies
|
||||||
* the offline messages to retrieve. The returned offline messages will not be deleted
|
* the offline messages to retrieve. The returned offline messages will not be deleted
|
||||||
* from the server. Use {@link #deleteMessages(java.util.List)} to delete the messages.
|
* from the server. Use {@link #deleteMessages(java.util.List)} to delete the messages.
|
||||||
*
|
*
|
||||||
* @param nodes the list of stamps that uniquely identifies offline message.
|
* @param nodes the list of stamps that uniquely identifies offline message.
|
||||||
* @return an Iterator with the offline <tt>Messages</tt> that were received as part of
|
* @return a List with the offline <tt>Messages</tt> that were received as part of
|
||||||
* this request.
|
* this request.
|
||||||
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
|
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
|
||||||
* not support offline message retrieval.
|
* not support offline message retrieval.
|
||||||
* @throws NoResponseException if there was no response from the server.
|
* @throws NoResponseException if there was no response from the server.
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
public Iterator<Message> getMessages(final List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
public List<Message> getMessages(final List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
List<Message> messages = new ArrayList<Message>();
|
List<Message> messages = new ArrayList<Message>();
|
||||||
OfflineMessageRequest request = new OfflineMessageRequest();
|
OfflineMessageRequest request = new OfflineMessageRequest();
|
||||||
for (String node : nodes) {
|
for (String node : nodes) {
|
||||||
|
@ -169,7 +168,7 @@ public class OfflineMessageManager {
|
||||||
}
|
}
|
||||||
// Stop queuing offline messages
|
// Stop queuing offline messages
|
||||||
messageCollector.cancel();
|
messageCollector.cancel();
|
||||||
return messages.iterator();
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,13 +176,13 @@ public class OfflineMessageManager {
|
||||||
* messages will not be deleted from the server. Use {@link #deleteMessages(java.util.List)}
|
* messages will not be deleted from the server. Use {@link #deleteMessages(java.util.List)}
|
||||||
* to delete the messages.
|
* to delete the messages.
|
||||||
*
|
*
|
||||||
* @return an Iterator with all the offline <tt>Messages</tt> of the user.
|
* @return a List with all the offline <tt>Messages</tt> of the user.
|
||||||
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
|
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
|
||||||
* not support offline message retrieval.
|
* not support offline message retrieval.
|
||||||
* @throws NoResponseException if there was no response from the server.
|
* @throws NoResponseException if there was no response from the server.
|
||||||
* @throws NotConnectedException
|
* @throws NotConnectedException
|
||||||
*/
|
*/
|
||||||
public Iterator<Message> getMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
public List<Message> getMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
|
||||||
List<Message> messages = new ArrayList<Message>();
|
List<Message> messages = new ArrayList<Message>();
|
||||||
OfflineMessageRequest request = new OfflineMessageRequest();
|
OfflineMessageRequest request = new OfflineMessageRequest();
|
||||||
request.setFetch(true);
|
request.setFetch(true);
|
||||||
|
@ -200,7 +199,7 @@ public class OfflineMessageManager {
|
||||||
}
|
}
|
||||||
// Stop queuing offline messages
|
// Stop queuing offline messages
|
||||||
messageCollector.cancel();
|
messageCollector.cancel();
|
||||||
return messages.iterator();
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,8 +22,8 @@ import org.jivesoftware.smack.provider.IQProvider;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,15 +39,15 @@ public class OfflineMessageRequest extends IQ {
|
||||||
private boolean fetch = false;
|
private boolean fetch = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for item childs that holds information about offline messages to
|
* Returns a Collection of item childs that holds information about offline messages to
|
||||||
* view or delete.
|
* view or delete.
|
||||||
*
|
*
|
||||||
* @return an Iterator for item childs that holds information about offline messages to
|
* @return a Collection of item childs that holds information about offline messages to
|
||||||
* view or delete.
|
* view or delete.
|
||||||
*/
|
*/
|
||||||
public Iterator<Item> getItems() {
|
public Collection<Item> getItems() {
|
||||||
synchronized (items) {
|
synchronized (items) {
|
||||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Item>(items));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.jivesoftware.smackx.pubsub;
|
package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.xdata.Form;
|
import org.jivesoftware.smackx.xdata.Form;
|
||||||
|
@ -123,9 +122,9 @@ public class ConfigureForm extends Form
|
||||||
/**
|
/**
|
||||||
* The id's of the child nodes associated with a collection node (both leaf and collection).
|
* The id's of the child nodes associated with a collection node (both leaf and collection).
|
||||||
*
|
*
|
||||||
* @return Iterator over the list of child nodes.
|
* @return list of child nodes.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getChildren()
|
public List<String> getChildren()
|
||||||
{
|
{
|
||||||
return getFieldValues(ConfigureNodeFields.children);
|
return getFieldValues(ConfigureNodeFields.children);
|
||||||
}
|
}
|
||||||
|
@ -170,13 +169,13 @@ public class ConfigureForm extends Form
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterator of JID's that are on the whitelist that determines who can associate child nodes
|
* List of JID's that are on the whitelist that determines who can associate child nodes
|
||||||
* with the collection node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
|
* with the collection node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
|
||||||
* {@link ChildrenAssociationPolicy#whitelist}.
|
* {@link ChildrenAssociationPolicy#whitelist}.
|
||||||
*
|
*
|
||||||
* @return Iterator over whitelist
|
* @return List of the whitelist
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getChildrenAssociationWhitelist()
|
public List<String> getChildrenAssociationWhitelist()
|
||||||
{
|
{
|
||||||
return getFieldValues(ConfigureNodeFields.children_association_whitelist);
|
return getFieldValues(ConfigureNodeFields.children_association_whitelist);
|
||||||
}
|
}
|
||||||
|
@ -512,11 +511,11 @@ public class ConfigureForm extends Form
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterator over the multi user chat rooms that are specified as reply rooms.
|
* List of the multi user chat rooms that are specified as reply rooms.
|
||||||
*
|
*
|
||||||
* @return The reply room JID's
|
* @return The reply room JID's
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getReplyRoom()
|
public List<String> getReplyRoom()
|
||||||
{
|
{
|
||||||
return getFieldValues(ConfigureNodeFields.replyroom);
|
return getFieldValues(ConfigureNodeFields.replyroom);
|
||||||
}
|
}
|
||||||
|
@ -537,7 +536,7 @@ public class ConfigureForm extends Form
|
||||||
*
|
*
|
||||||
* @return The JID's
|
* @return The JID's
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getReplyTo()
|
public List<String> getReplyTo()
|
||||||
{
|
{
|
||||||
return getFieldValues(ConfigureNodeFields.replyto);
|
return getFieldValues(ConfigureNodeFields.replyto);
|
||||||
}
|
}
|
||||||
|
@ -558,7 +557,7 @@ public class ConfigureForm extends Form
|
||||||
*
|
*
|
||||||
* @return The roster groups
|
* @return The roster groups
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getRosterGroupsAllowed()
|
public List<String> getRosterGroupsAllowed()
|
||||||
{
|
{
|
||||||
return getFieldValues(ConfigureNodeFields.roster_groups_allowed);
|
return getFieldValues(ConfigureNodeFields.roster_groups_allowed);
|
||||||
}
|
}
|
||||||
|
@ -642,23 +641,18 @@ public class ConfigureForm extends Form
|
||||||
{
|
{
|
||||||
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
|
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
|
||||||
|
|
||||||
Iterator<FormField> fields = getFields();
|
for (FormField formField : getFields())
|
||||||
|
|
||||||
while (fields.hasNext())
|
|
||||||
{
|
{
|
||||||
FormField formField = fields.next();
|
|
||||||
result.append('(');
|
result.append('(');
|
||||||
result.append(formField.getVariable());
|
result.append(formField.getVariable());
|
||||||
result.append(':');
|
result.append(':');
|
||||||
|
|
||||||
Iterator<String> values = formField.getValues();
|
|
||||||
StringBuilder valuesBuilder = new StringBuilder();
|
StringBuilder valuesBuilder = new StringBuilder();
|
||||||
|
|
||||||
while (values.hasNext())
|
for (String value : formField.getValues())
|
||||||
{
|
{
|
||||||
if (valuesBuilder.length() > 0)
|
if (valuesBuilder.length() > 0)
|
||||||
result.append(',');
|
result.append(',');
|
||||||
String value = (String)values.next();
|
|
||||||
valuesBuilder.append(value);
|
valuesBuilder.append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,10 +674,10 @@ public class ConfigureForm extends Form
|
||||||
{
|
{
|
||||||
FormField formField = getField(field.getFieldName());
|
FormField formField = getField(field.getFieldName());
|
||||||
|
|
||||||
return (formField.getValues().hasNext()) ? formField.getValues().next() : null;
|
return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterator<String> getFieldValues(ConfigureNodeFields field)
|
private List<String> getFieldValues(ConfigureNodeFields field)
|
||||||
{
|
{
|
||||||
FormField formField = getField(field.getFieldName());
|
FormField formField = getField(field.getFieldName());
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -450,14 +449,12 @@ abstract public class Node
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
|
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
|
||||||
Collection<? extends PacketExtension> pubItems = itemsElem.getItems();
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Iterator<RetractItem> it = (Iterator<RetractItem>)pubItems.iterator();
|
Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems();
|
||||||
List<String> items = new ArrayList<String>(pubItems.size());
|
List<String> items = new ArrayList<String>(pubItems.size());
|
||||||
|
|
||||||
while (it.hasNext())
|
for (RetractItem item : pubItems)
|
||||||
{
|
{
|
||||||
RetractItem item = it.next();
|
|
||||||
items.add(item.getId());
|
items.add(item.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ final public class PubSubManager
|
||||||
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
|
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
|
||||||
|
|
||||||
if (nodeTypeField != null)
|
if (nodeTypeField != null)
|
||||||
isLeafNode = nodeTypeField.getValues().next().equals(NodeType.leaf.toString());
|
isLeafNode = nodeTypeField.getValues().get(0).equals(NodeType.leaf.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errors will cause exceptions in getReply, so it only returns
|
// Errors will cause exceptions in getReply, so it only returns
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.List;
|
||||||
import java.util.UnknownFormatConversionException;
|
import java.util.UnknownFormatConversionException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.util.XmppDateTime;
|
import org.jivesoftware.smack.util.XmppDateTime;
|
||||||
|
@ -176,19 +176,17 @@ public class SubscribeForm extends Form
|
||||||
* Gets the {@link PresenceState} for which an entity wants to receive
|
* Gets the {@link PresenceState} for which an entity wants to receive
|
||||||
* notifications.
|
* notifications.
|
||||||
*
|
*
|
||||||
* @return iterator over the list of states
|
* @return the list of states
|
||||||
*/
|
*/
|
||||||
public Iterator<PresenceState> getShowValues()
|
public List<PresenceState> getShowValues()
|
||||||
{
|
{
|
||||||
ArrayList<PresenceState> result = new ArrayList<PresenceState>(5);
|
ArrayList<PresenceState> result = new ArrayList<PresenceState>(5);
|
||||||
Iterator<String > it = getFieldValues(SubscribeOptionFields.show_values);
|
|
||||||
|
|
||||||
while (it.hasNext())
|
for (String state : getFieldValues(SubscribeOptionFields.show_values))
|
||||||
{
|
{
|
||||||
String state = it.next();
|
|
||||||
result.add(PresenceState.valueOf(state));
|
result.add(PresenceState.valueOf(state));
|
||||||
}
|
}
|
||||||
return result.iterator();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,10 +217,10 @@ public class SubscribeForm extends Form
|
||||||
{
|
{
|
||||||
FormField formField = getField(field.getFieldName());
|
FormField formField = getField(field.getFieldName());
|
||||||
|
|
||||||
return formField.getValues().next();
|
return formField.getValues().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterator<String> getFieldValues(SubscribeOptionFields field)
|
private List<String> getFieldValues(SubscribeOptionFields field)
|
||||||
{
|
{
|
||||||
FormField formField = getField(field.getFieldName());
|
FormField formField = getField(field.getFieldName());
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.jivesoftware.smackx.xdata.packet.DataForm.Item;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,22 +66,18 @@ public class ReportedData {
|
||||||
*/
|
*/
|
||||||
private ReportedData(DataForm dataForm) {
|
private ReportedData(DataForm dataForm) {
|
||||||
// Add the columns to the report based on the reported data fields
|
// Add the columns to the report based on the reported data fields
|
||||||
for (Iterator<FormField> fields = dataForm.getReportedData().getFields(); fields.hasNext();) {
|
for (FormField field : dataForm.getReportedData().getFields()) {
|
||||||
FormField field = fields.next();
|
|
||||||
columns.add(new Column(field.getLabel(), field.getVariable(), field.getType()));
|
columns.add(new Column(field.getLabel(), field.getVariable(), field.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the rows to the report based on the form's items
|
// Add the rows to the report based on the form's items
|
||||||
for (Iterator<Item> items = dataForm.getItems(); items.hasNext();) {
|
for (Item item : dataForm.getItems()) {
|
||||||
Item item = items.next();
|
|
||||||
List<Field> fieldList = new ArrayList<Field>(columns.size());
|
List<Field> fieldList = new ArrayList<Field>(columns.size());
|
||||||
FormField field;
|
for (FormField field : item.getFields()) {
|
||||||
for (Iterator<FormField> fields = item.getFields(); fields.hasNext();) {
|
|
||||||
field = fields.next();
|
|
||||||
// The field is created with all the values of the data form's field
|
// The field is created with all the values of the data form's field
|
||||||
List<String> values = new ArrayList<String>();
|
List<String> values = new ArrayList<String>();
|
||||||
for (Iterator<String> it=field.getValues(); it.hasNext();) {
|
for (String value : field.getValues()) {
|
||||||
values.add(it.next());
|
values.add(value);
|
||||||
}
|
}
|
||||||
fieldList.add(new Field(field.getVariable(), values));
|
fieldList.add(new Field(field.getVariable(), values));
|
||||||
}
|
}
|
||||||
|
@ -116,21 +111,21 @@ public class ReportedData {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the rows returned from a search.
|
* Returns a List of the rows returned from a search.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the rows returned from a search.
|
* @return a List of the rows returned from a search.
|
||||||
*/
|
*/
|
||||||
public Iterator<Row> getRows() {
|
public List<Row> getRows() {
|
||||||
return Collections.unmodifiableList(new ArrayList<Row>(rows)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Row>(rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the columns returned from a search.
|
* Returns a List of the columns returned from a search.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the columns returned from a search.
|
* @return a List of the columns returned from a search.
|
||||||
*/
|
*/
|
||||||
public Iterator<Column> getColumns() {
|
public List<Column> getColumns() {
|
||||||
return Collections.unmodifiableList(new ArrayList<Column>(columns)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Column>(columns));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,9 +224,8 @@ public class ReportedData {
|
||||||
* @param variable the variable to match.
|
* @param variable the variable to match.
|
||||||
* @return the values of the field whose variable matches the requested variable.
|
* @return the values of the field whose variable matches the requested variable.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getValues(String variable) {
|
public List<String> getValues(String variable) {
|
||||||
for(Iterator<Field> it=getFields();it.hasNext();) {
|
for(Field field : getFields()) {
|
||||||
Field field = it.next();
|
|
||||||
if (variable.equalsIgnoreCase(field.getVariable())) {
|
if (variable.equalsIgnoreCase(field.getVariable())) {
|
||||||
return field.getValues();
|
return field.getValues();
|
||||||
}
|
}
|
||||||
|
@ -244,8 +238,8 @@ public class ReportedData {
|
||||||
*
|
*
|
||||||
* @return the fields that define the data that goes with the item.
|
* @return the fields that define the data that goes with the item.
|
||||||
*/
|
*/
|
||||||
private Iterator<Field> getFields() {
|
private List<Field> getFields() {
|
||||||
return Collections.unmodifiableList(new ArrayList<Field>(fields)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Field>(fields));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,12 +262,12 @@ public class ReportedData {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterator on the values reported as part of the search.
|
* Returns a List of the values reported as part of the search.
|
||||||
*
|
*
|
||||||
* @return the returned values of the search.
|
* @return the returned values of the search.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getValues() {
|
public List<String> getValues() {
|
||||||
return Collections.unmodifiableList(values).iterator();
|
return Collections.unmodifiableList(values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.jivesoftware.smackx.xdata.FormField;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,9 +64,7 @@ class SimpleUserSearch extends IQ {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<FormField> fields = form.getFields();
|
for (FormField field : form.getFields()) {
|
||||||
while (fields.hasNext()) {
|
|
||||||
FormField field = fields.next();
|
|
||||||
String name = field.getVariable();
|
String name = field.getVariable();
|
||||||
String value = getSingleValue(field);
|
String value = getSingleValue(field);
|
||||||
if (value.trim().length() > 0) {
|
if (value.trim().length() > 0) {
|
||||||
|
@ -79,11 +76,12 @@ class SimpleUserSearch extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getSingleValue(FormField formField) {
|
private static String getSingleValue(FormField formField) {
|
||||||
Iterator<String> values = formField.getValues();
|
List<String> values = formField.getValues();
|
||||||
while (values.hasNext()) {
|
if (values.isEmpty()) {
|
||||||
return values.next();
|
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
|
} else {
|
||||||
|
return values.get(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parseItems(XmlPullParser parser) throws Exception {
|
protected void parseItems(XmlPullParser parser) throws Exception {
|
||||||
|
@ -121,11 +119,10 @@ class SimpleUserSearch extends IQ {
|
||||||
fields.add(field);
|
fields.add(field);
|
||||||
|
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
Iterator<ReportedData.Column> cols = data.getColumns();
|
for (ReportedData.Column column : data.getColumns()) {
|
||||||
while (cols.hasNext()) {
|
|
||||||
ReportedData.Column column = cols.next();
|
|
||||||
if (column.getVariable().equals(name)) {
|
if (column.getVariable().equals(name)) {
|
||||||
exists = true;
|
exists = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.jivesoftware.smack.provider.IQProvider;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,8 +48,8 @@ public class SharedGroupsInfo extends IQ {
|
||||||
public String getChildElementXML() {
|
public String getChildElementXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<sharedgroup xmlns=\"http://www.jivesoftware.org/protocol/sharedgroup\">");
|
buf.append("<sharedgroup xmlns=\"http://www.jivesoftware.org/protocol/sharedgroup\">");
|
||||||
for (Iterator<String> it=groups.iterator(); it.hasNext();) {
|
for (String group : groups) {
|
||||||
buf.append("<group>").append(it.next()).append("</group>");
|
buf.append("<group>").append(group).append("</group>");
|
||||||
}
|
}
|
||||||
buf.append("</sharedgroup>");
|
buf.append("</sharedgroup>");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
|
|
@ -27,7 +27,6 @@ import java.net.URL;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -754,9 +753,7 @@ public class VCard extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendPhones(Map<String, String> phones, final String code) {
|
private void appendPhones(Map<String, String> phones, final String code) {
|
||||||
Iterator<Map.Entry<String, String>> it = phones.entrySet().iterator();
|
for (final Map.Entry<String,String> entry : phones.entrySet()) {
|
||||||
while (it.hasNext()) {
|
|
||||||
final Map.Entry<String,String> entry = it.next();
|
|
||||||
appendTag("TEL", true, new ContentBuilder() {
|
appendTag("TEL", true, new ContentBuilder() {
|
||||||
public void addTagContent() {
|
public void addTagContent() {
|
||||||
appendEmptyTag(entry.getKey());
|
appendEmptyTag(entry.getKey());
|
||||||
|
@ -773,9 +770,7 @@ public class VCard extends IQ {
|
||||||
public void addTagContent() {
|
public void addTagContent() {
|
||||||
appendEmptyTag(code);
|
appendEmptyTag(code);
|
||||||
|
|
||||||
Iterator<Map.Entry<String, String>> it = addr.entrySet().iterator();
|
for (final Entry<String, String> entry : addr.entrySet()) {
|
||||||
while (it.hasNext()) {
|
|
||||||
final Entry<String, String> entry = it.next();
|
|
||||||
appendTag(entry.getKey(), StringUtils.escapeForXML(entry.getValue()));
|
appendTag(entry.getKey(), StringUtils.escapeForXML(entry.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -788,16 +783,12 @@ public class VCard extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendGenericFields() {
|
private void appendGenericFields() {
|
||||||
Iterator<Map.Entry<String, String>> it = otherSimpleFields.entrySet().iterator();
|
for (Map.Entry<String, String> entry : otherSimpleFields.entrySet()) {
|
||||||
while (it.hasNext()) {
|
|
||||||
Map.Entry<String, String> entry = it.next();
|
|
||||||
appendTag(entry.getKey().toString(),
|
appendTag(entry.getKey().toString(),
|
||||||
StringUtils.escapeForXML(entry.getValue()));
|
StringUtils.escapeForXML(entry.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
it = otherUnescapableFields.entrySet().iterator();
|
for (Map.Entry<String, String> entry : otherUnescapableFields.entrySet()) {
|
||||||
while (it.hasNext()) {
|
|
||||||
Map.Entry<String, String> entry = it.next();
|
|
||||||
appendTag(entry.getKey().toString(),entry.getValue());
|
appendTag(entry.getKey().toString(),entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,8 +342,8 @@ public class Form {
|
||||||
// Clear the old values
|
// Clear the old values
|
||||||
field.resetValues();
|
field.resetValues();
|
||||||
// Set the default value
|
// Set the default value
|
||||||
for (Iterator<String> it = field.getValues(); it.hasNext();) {
|
for (String value : field.getValues()) {
|
||||||
field.addValue(it.next());
|
field.addValue(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -352,11 +352,11 @@ public class Form {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the fields that are part of the form.
|
* Returns a List of the fields that are part of the form.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the fields that are part of the form.
|
* @return a List of the fields that are part of the form.
|
||||||
*/
|
*/
|
||||||
public Iterator<FormField> getFields() {
|
public List<FormField> getFields() {
|
||||||
return dataForm.getFields();
|
return dataForm.getFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,9 +373,7 @@ public class Form {
|
||||||
throw new IllegalArgumentException("Variable must not be null or blank.");
|
throw new IllegalArgumentException("Variable must not be null or blank.");
|
||||||
}
|
}
|
||||||
// Look for the field whose variable matches the requested variable
|
// Look for the field whose variable matches the requested variable
|
||||||
FormField field;
|
for (FormField field : getFields()) {
|
||||||
for (Iterator<FormField> it=getFields();it.hasNext();) {
|
|
||||||
field = it.next();
|
|
||||||
if (variable.equals(field.getVariable())) {
|
if (variable.equals(field.getVariable())) {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
@ -391,7 +389,7 @@ public class Form {
|
||||||
public String getInstructions() {
|
public String getInstructions() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// Join the list of instructions together separated by newlines
|
// Join the list of instructions together separated by newlines
|
||||||
for (Iterator<String> it = dataForm.getInstructions(); it.hasNext();) {
|
for (Iterator<String> it = dataForm.getInstructions().iterator(); it.hasNext();) {
|
||||||
sb.append(it.next());
|
sb.append(it.next());
|
||||||
// If this is not the last instruction then append a newline
|
// If this is not the last instruction then append a newline
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
|
@ -472,9 +470,8 @@ public class Form {
|
||||||
if (isSubmitType()) {
|
if (isSubmitType()) {
|
||||||
// Create a new DataForm that contains only the answered fields
|
// Create a new DataForm that contains only the answered fields
|
||||||
DataForm dataFormToSend = new DataForm(getType());
|
DataForm dataFormToSend = new DataForm(getType());
|
||||||
for(Iterator<FormField> it=getFields();it.hasNext();) {
|
for(FormField field : getFields()) {
|
||||||
FormField field = it.next();
|
if (!field.getValues().isEmpty()) {
|
||||||
if (field.getValues().hasNext()) {
|
|
||||||
dataFormToSend.addField(field);
|
dataFormToSend.addField(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -521,8 +518,7 @@ public class Form {
|
||||||
}
|
}
|
||||||
// Create a new Form
|
// Create a new Form
|
||||||
Form form = new Form(TYPE_SUBMIT);
|
Form form = new Form(TYPE_SUBMIT);
|
||||||
for (Iterator<FormField> fields=getFields(); fields.hasNext();) {
|
for (FormField field : getFields()) {
|
||||||
FormField field = fields.next();
|
|
||||||
// Add to the new form any type of field that includes a variable.
|
// Add to the new form any type of field that includes a variable.
|
||||||
// Note: The fields of type FIXED are the only ones that don't specify a variable
|
// Note: The fields of type FIXED are the only ones that don't specify a variable
|
||||||
if (field.getVariable() != null) {
|
if (field.getVariable() != null) {
|
||||||
|
@ -534,8 +530,8 @@ public class Form {
|
||||||
// Since a hidden field could have many values we need to collect them
|
// Since a hidden field could have many values we need to collect them
|
||||||
// in a list
|
// in a list
|
||||||
List<String> values = new ArrayList<String>();
|
List<String> values = new ArrayList<String>();
|
||||||
for (Iterator<String> it=field.getValues();it.hasNext();) {
|
for (String value : field.getValues()) {
|
||||||
values.add(it.next());
|
values.add(value);
|
||||||
}
|
}
|
||||||
form.setAnswer(field.getVariable(), values);
|
form.setAnswer(field.getVariable(), values);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,14 +94,14 @@ public class FormField {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the available options that the user has in order to answer
|
* Returns a List of the available options that the user has in order to answer
|
||||||
* the question.
|
* the question.
|
||||||
*
|
*
|
||||||
* @return Iterator for the available options.
|
* @return List of the available options.
|
||||||
*/
|
*/
|
||||||
public Iterator<Option> getOptions() {
|
public List<Option> getOptions() {
|
||||||
synchronized (options) {
|
synchronized (options) {
|
||||||
return Collections.unmodifiableList(new ArrayList<Option>(options)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Option>(options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,15 +140,15 @@ public class FormField {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the default values of the question if the question is part
|
* Returns a List of the default values of the question if the question is part
|
||||||
* of a form to fill out. Otherwise, returns an Iterator for the answered values of
|
* of a form to fill out. Otherwise, returns a List of the answered values of
|
||||||
* the question.
|
* the question.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the default values or answered values of the question.
|
* @return a List of the default values or answered values of the question.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getValues() {
|
public List<String> getValues() {
|
||||||
synchronized (values) {
|
synchronized (values) {
|
||||||
return Collections.unmodifiableList(new ArrayList<String>(values)).iterator();
|
return Collections.unmodifiableList(new ArrayList<String>(values));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,12 +283,12 @@ public class FormField {
|
||||||
buf.append("<required/>");
|
buf.append("<required/>");
|
||||||
}
|
}
|
||||||
// Loop through all the values and append them to the string buffer
|
// Loop through all the values and append them to the string buffer
|
||||||
for (Iterator<String> i = getValues(); i.hasNext();) {
|
for (String value : getValues()) {
|
||||||
buf.element("value", i.next());
|
buf.element("value", value);
|
||||||
}
|
}
|
||||||
// Loop through all the values and append them to the string buffer
|
// Loop through all the values and append them to the string buffer
|
||||||
for (Iterator<Option> i = getOptions(); i.hasNext();) {
|
for (Option option : getOptions()) {
|
||||||
buf.append((i.next()).toXML());
|
buf.append(option.toXML());
|
||||||
}
|
}
|
||||||
buf.append("</field>");
|
buf.append("</field>");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
|
|
|
@ -23,7 +23,6 @@ import org.jivesoftware.smackx.xdata.FormField;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,16 +75,16 @@ public class DataForm implements PacketExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the list of instructions that explain how to fill out the form and
|
* Returns a List of the list of instructions that explain how to fill out the form and
|
||||||
* what the form is about. The dataform could include multiple instructions since each
|
* what the form is about. The dataform could include multiple instructions since each
|
||||||
* instruction could not contain newlines characters. Join the instructions together in order
|
* instruction could not contain newlines characters. Join the instructions together in order
|
||||||
* to show them to the user.
|
* to show them to the user.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the list of instructions that explain how to fill out the form.
|
* @return a List of the list of instructions that explain how to fill out the form.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getInstructions() {
|
public List<String> getInstructions() {
|
||||||
synchronized (instructions) {
|
synchronized (instructions) {
|
||||||
return Collections.unmodifiableList(new ArrayList<String>(instructions)).iterator();
|
return Collections.unmodifiableList(new ArrayList<String>(instructions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,24 +98,24 @@ public class DataForm implements PacketExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the items returned from a search.
|
* Returns a List of the items returned from a search.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the items returned from a search.
|
* @return a List of the items returned from a search.
|
||||||
*/
|
*/
|
||||||
public Iterator<Item> getItems() {
|
public List<Item> getItems() {
|
||||||
synchronized (items) {
|
synchronized (items) {
|
||||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
return Collections.unmodifiableList(new ArrayList<Item>(items));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the fields that are part of the form.
|
* Returns a List of the fields that are part of the form.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the fields that are part of the form.
|
* @return a List of the fields that are part of the form.
|
||||||
*/
|
*/
|
||||||
public Iterator<FormField> getFields() {
|
public List<FormField> getFields() {
|
||||||
synchronized (fields) {
|
synchronized (fields) {
|
||||||
return Collections.unmodifiableList(new ArrayList<FormField>(fields)).iterator();
|
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,21 +214,19 @@ public class DataForm implements PacketExtension {
|
||||||
if (getTitle() != null) {
|
if (getTitle() != null) {
|
||||||
buf.append("<title>").append(getTitle()).append("</title>");
|
buf.append("<title>").append(getTitle()).append("</title>");
|
||||||
}
|
}
|
||||||
for (Iterator<String> it=getInstructions(); it.hasNext();) {
|
for (String instruction : getInstructions()) {
|
||||||
buf.append("<instructions>").append(it.next()).append("</instructions>");
|
buf.append("<instructions>").append(instruction).append("</instructions>");
|
||||||
}
|
}
|
||||||
// Append the list of fields returned from a search
|
// Append the list of fields returned from a search
|
||||||
if (getReportedData() != null) {
|
if (getReportedData() != null) {
|
||||||
buf.append(getReportedData().toXML());
|
buf.append(getReportedData().toXML());
|
||||||
}
|
}
|
||||||
// Loop through all the items returned from a search and append them to the string buffer
|
// Loop through all the items returned from a search and append them to the string buffer
|
||||||
for (Iterator<Item> i = getItems(); i.hasNext();) {
|
for (Item item : getItems()) {
|
||||||
Item item = i.next();
|
|
||||||
buf.append(item.toXML());
|
buf.append(item.toXML());
|
||||||
}
|
}
|
||||||
// Loop through all the form fields and append them to the string buffer
|
// Loop through all the form fields and append them to the string buffer
|
||||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
for (FormField field : getFields()) {
|
||||||
FormField field = i.next();
|
|
||||||
buf.append(field.toXML());
|
buf.append(field.toXML());
|
||||||
}
|
}
|
||||||
buf.append("</").append(getElementName()).append(">");
|
buf.append("</").append(getElementName()).append(">");
|
||||||
|
@ -255,16 +252,15 @@ public class DataForm implements PacketExtension {
|
||||||
*
|
*
|
||||||
* @return the fields returned from a search.
|
* @return the fields returned from a search.
|
||||||
*/
|
*/
|
||||||
public Iterator<FormField> getFields() {
|
public List<FormField> getFields() {
|
||||||
return Collections.unmodifiableList(new ArrayList<FormField>(fields)).iterator();
|
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXML() {
|
public String toXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<reported>");
|
buf.append("<reported>");
|
||||||
// Loop through all the form items and append them to the string buffer
|
// Loop through all the form items and append them to the string buffer
|
||||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
for (FormField field : getFields()) {
|
||||||
FormField field = i.next();
|
|
||||||
buf.append(field.toXML());
|
buf.append(field.toXML());
|
||||||
}
|
}
|
||||||
buf.append("</reported>");
|
buf.append("</reported>");
|
||||||
|
@ -290,16 +286,15 @@ public class DataForm implements PacketExtension {
|
||||||
*
|
*
|
||||||
* @return the fields that define the data that goes with the item.
|
* @return the fields that define the data that goes with the item.
|
||||||
*/
|
*/
|
||||||
public Iterator<FormField> getFields() {
|
public List<FormField> getFields() {
|
||||||
return Collections.unmodifiableList(new ArrayList<FormField>(fields)).iterator();
|
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXML() {
|
public String toXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<item>");
|
buf.append("<item>");
|
||||||
// Loop through all the form items and append them to the string buffer
|
// Loop through all the form items and append them to the string buffer
|
||||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
for (FormField field : getFields()) {
|
||||||
FormField field = i.next();
|
|
||||||
buf.append(field.toXML());
|
buf.append(field.toXML());
|
||||||
}
|
}
|
||||||
buf.append("</item>");
|
buf.append("</item>");
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.xevent;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -198,18 +197,18 @@ public class MessageEventManager {
|
||||||
(MessageEvent) message.getExtension("x", "jabber:x:event");
|
(MessageEvent) message.getExtension("x", "jabber:x:event");
|
||||||
if (messageEvent.isMessageEventRequest()) {
|
if (messageEvent.isMessageEventRequest()) {
|
||||||
// Fire event for requests of message events
|
// Fire event for requests of message events
|
||||||
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
|
for (String eventType : messageEvent.getEventTypes())
|
||||||
fireMessageEventRequestListeners(
|
fireMessageEventRequestListeners(
|
||||||
message.getFrom(),
|
message.getFrom(),
|
||||||
message.getPacketID(),
|
message.getPacketID(),
|
||||||
it.next().concat("NotificationRequested"));
|
eventType.concat("NotificationRequested"));
|
||||||
} else
|
} else
|
||||||
// Fire event for notifications of message events
|
// Fire event for notifications of message events
|
||||||
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
|
for (String eventType : messageEvent.getEventTypes())
|
||||||
fireMessageEventNotificationListeners(
|
fireMessageEventNotificationListeners(
|
||||||
message.getFrom(),
|
message.getFrom(),
|
||||||
messageEvent.getPacketID(),
|
messageEvent.getPacketID(),
|
||||||
it.next().concat("Notification"));
|
eventType.concat("Notification"));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smackx.xevent.packet;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents message events relating to the delivery, display, composition and cancellation of
|
* Represents message events relating to the delivery, display, composition and cancellation of
|
||||||
|
@ -162,9 +162,9 @@ public class MessageEvent implements PacketExtension {
|
||||||
* Returns the types of events. The type of event could be:
|
* Returns the types of events. The type of event could be:
|
||||||
* "offline", "composing","delivered","displayed", "offline"
|
* "offline", "composing","delivered","displayed", "offline"
|
||||||
*
|
*
|
||||||
* @return an iterator over all the types of events of the MessageEvent.
|
* @return a List of all the types of events of the MessageEvent.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getEventTypes() {
|
public List<String> getEventTypes() {
|
||||||
ArrayList<String> allEvents = new ArrayList<String>();
|
ArrayList<String> allEvents = new ArrayList<String>();
|
||||||
if (isDelivered()) {
|
if (isDelivered()) {
|
||||||
allEvents.add(MessageEvent.DELIVERED);
|
allEvents.add(MessageEvent.DELIVERED);
|
||||||
|
@ -181,7 +181,7 @@ public class MessageEvent implements PacketExtension {
|
||||||
if (isOffline()) {
|
if (isOffline()) {
|
||||||
allEvents.add(MessageEvent.OFFLINE);
|
allEvents.add(MessageEvent.OFFLINE);
|
||||||
}
|
}
|
||||||
return allEvents.iterator();
|
return allEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.xhtmlim.packet.XHTMLExtension;
|
import org.jivesoftware.smackx.xhtmlim.packet.XHTMLExtension;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages XHTML formatted texts within messages. A XHTMLManager provides a high level access to
|
* Manages XHTML formatted texts within messages. A XHTMLManager provides a high level access to
|
||||||
|
@ -55,7 +55,7 @@ public class XHTMLManager {
|
||||||
* @param message an XHTML message
|
* @param message an XHTML message
|
||||||
* @return an Iterator for the bodies in the message or null if none.
|
* @return an Iterator for the bodies in the message or null if none.
|
||||||
*/
|
*/
|
||||||
public static Iterator<String> getBodies(Message message) {
|
public static List<String> getBodies(Message message) {
|
||||||
XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
|
XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
|
||||||
if (xhtmlExtension != null)
|
if (xhtmlExtension != null)
|
||||||
return xhtmlExtension.getBodies();
|
return xhtmlExtension.getBodies();
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,21 +81,21 @@ public class XHTMLExtension implements PacketExtension {
|
||||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||||
"\">");
|
"\">");
|
||||||
// Loop through all the bodies and append them to the string buffer
|
// Loop through all the bodies and append them to the string buffer
|
||||||
for (Iterator<String> i = getBodies(); i.hasNext();) {
|
for (String body : getBodies()) {
|
||||||
buf.append(i.next());
|
buf.append(body);
|
||||||
}
|
}
|
||||||
buf.append("</").append(getElementName()).append(">");
|
buf.append("</").append(getElementName()).append(">");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an Iterator for the bodies in the packet.
|
* Returns a List of the bodies in the packet.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the bodies in the packet.
|
* @return a List of the bodies in the packet.
|
||||||
*/
|
*/
|
||||||
public Iterator<String> getBodies() {
|
public List<String> getBodies() {
|
||||||
synchronized (bodies) {
|
synchronized (bodies) {
|
||||||
return Collections.unmodifiableList(new ArrayList<String>(bodies)).iterator();
|
return Collections.unmodifiableList(new ArrayList<String>(bodies));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class XHTMLExtensionProviderTest {
|
||||||
assertThat(extension, is(instanceOf(XHTMLExtension.class)));
|
assertThat(extension, is(instanceOf(XHTMLExtension.class)));
|
||||||
XHTMLExtension attachmentsInfo = (XHTMLExtension) extension;
|
XHTMLExtension attachmentsInfo = (XHTMLExtension) extension;
|
||||||
|
|
||||||
assertEquals(sampleXhtml(), attachmentsInfo.getBodies().next());
|
assertEquals(sampleXhtml(), attachmentsInfo.getBodies().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sampleXhtml() {
|
private String sampleXhtml() {
|
||||||
|
|
Loading…
Reference in a new issue