1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 00:02:06 +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:
Florian Schmaus 2014-04-09 08:26:28 +02:00
parent 6ea1d65e73
commit 4cff008708
31 changed files with 219 additions and 282 deletions

View file

@ -22,7 +22,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -583,17 +582,18 @@ public class Roster {
* updates.
*
* @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
* is available.
*/
public Iterator<Presence> getPresences(String user) {
public Collection<Presence> getPresences(String user) {
Collection<Presence> res;
String key = getPresenceMapKey(user);
Map<String, Presence> userPresences = presenceMap.get(key);
if (userPresences == null) {
Presence presence = new Presence(Presence.Type.unavailable);
presence.setFrom(user);
return Arrays.asList(presence).iterator();
res = Arrays.asList(presence);
}
else {
Collection<Presence> answer = new ArrayList<Presence>();
@ -603,14 +603,15 @@ public class Roster {
}
}
if (!answer.isEmpty()) {
return answer.iterator();
res = answer;
}
else {
Presence presence = new Presence(Presence.Type.unavailable);
presence.setFrom(user);
return Arrays.asList(presence).iterator();
res = Arrays.asList(presence);
}
}
return Collections.unmodifiableCollection(res);
}
/**

View file

@ -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
* 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() {
if (applicationExtensions == null) {

View file

@ -93,13 +93,13 @@ information concerning a node named "http://jabber.org/protocol/muc#rooms": <br>
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
<font color="#0000FF">"http://jabber.org/protocol/muc#rooms"</font>,
new NodeInformationProvider() {
public Iterator getNodeItems() {
public List getNodeItems() {
ArrayList answer = new ArrayList();
Iterator rooms = MultiUserChat.getJoinedRooms(connection);
while (rooms.hasNext()) {
answer.add(new DiscoverItems.Item((String)rooms.next()));
}
return answer.iterator();
return answer;
}
});
</pre>

View file

@ -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() {
return Collections.unmodifiableList(new ArrayList<Rule>(rules)).iterator();
public Collection<Rule> getRules() {
return Collections.unmodifiableList(new ArrayList<Rule>(rules));
}
/**
@ -168,8 +168,8 @@ public class AMPExtension implements PacketExtension {
buf.append(">");
// Loop through all the rules and append them to the string buffer
for (Iterator<Rule> i = getRules(); i.hasNext();) {
buf.append(i.next().toXML());
for (Rule rule : getRules()) {
buf.append(rule.toXML());
}
buf.append("</").append(getElementName()).append(">");

View file

@ -23,7 +23,6 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@ -167,9 +166,7 @@ public class Bookmarks implements PrivateData {
StringBuilder buf = new StringBuilder();
buf.append("<storage xmlns=\"storage:bookmarks\">");
final Iterator<BookmarkedURL> urls = getBookmarkedURLS().iterator();
while (urls.hasNext()) {
BookmarkedURL urlStorage = urls.next();
for (BookmarkedURL urlStorage : getBookmarkedURLS()) {
if(urlStorage.isShared()) {
continue;
}
@ -182,9 +179,7 @@ public class Bookmarks implements PrivateData {
}
// Add Conference additions
final Iterator<BookmarkedConference> conferences = getBookmarkedConferences().iterator();
while (conferences.hasNext()) {
BookmarkedConference conference = conferences.next();
for (BookmarkedConference conference : getBookmarkedConferences()) {
if(conference.isShared()) {
continue;
}

View file

@ -51,7 +51,6 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@ -528,12 +527,10 @@ public class EntityCapsManager extends Manager {
*/
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
List<FormField> foundFormTypes = new LinkedList<FormField>();
for (Iterator<PacketExtension> i = info.getExtensions().iterator(); i.hasNext();) {
PacketExtension pe = i.next();
for (PacketExtension pe : info.getExtensions()) {
if (pe.getNamespace().equals(Form.NAMESPACE)) {
DataForm df = (DataForm) pe;
for (Iterator<FormField> it = df.getFields(); it.hasNext();) {
FormField f = it.next();
for (FormField f : df.getFields()) {
if (f.getVariable().equals("FORM_TYPE")) {
for (FormField fft : foundFormTypes) {
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,
// followed by the '<' character.
for (Iterator<DiscoverInfo.Identity> it = sortedIdentities.iterator(); it.hasNext();) {
DiscoverInfo.Identity identity = it.next();
for (DiscoverInfo.Identity identity : sortedIdentities) {
sb.append(identity.getCategory());
sb.append("/");
sb.append(identity.getType());
@ -623,8 +619,7 @@ public class EntityCapsManager extends Manager {
FormField ft = null;
for (Iterator<FormField> i = extendedInfo.getFields(); i.hasNext();) {
FormField f = i.next();
for (FormField f : extendedInfo.getFields()) {
if (!f.getVariable().equals("FORM_TYPE")) {
fs.add(f);
} else {
@ -664,10 +659,10 @@ public class EntityCapsManager extends Manager {
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>();
while (i.hasNext()) {
fvs.add(i.next());
for (String s : i) {
fvs.add(s);
}
for (String fv : fvs) {
sb.append(fv);

View file

@ -38,7 +38,6 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -314,8 +313,8 @@ public class ServiceDiscoveryManager extends Manager {
// Add the registered features to the response
synchronized (features) {
for (Iterator<String> it = getFeatures(); it.hasNext();) {
response.addFeature(it.next());
for (String feature : getFeatures()) {
response.addFeature(feature);
}
response.addExtension(extendedInfo);
}
@ -373,11 +372,11 @@ public class ServiceDiscoveryManager extends Manager {
/**
* 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) {
return Collections.unmodifiableList(new ArrayList<String>(features)).iterator();
return Collections.unmodifiableList(new ArrayList<String>(features));
}
}

View file

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
@ -280,15 +279,12 @@ public class FileTransferNegotiator {
}
private FormField getStreamMethodField(DataForm form) {
FormField field = null;
for (Iterator<FormField> it = form.getFields(); it.hasNext();) {
field = it.next();
for (FormField field : form.getFields()) {
if (field.getVariable().equals(STREAM_DATA_FIELD_NAME)) {
break;
return field;
}
field = null;
}
return field;
return null;
}
private StreamNegotiator getNegotiator(final FormField field)
@ -296,8 +292,8 @@ public class FileTransferNegotiator {
String variable;
boolean isByteStream = false;
boolean isIBB = false;
for (Iterator<FormField.Option> it = field.getOptions(); it.hasNext();) {
variable = it.next().getValue();
for (FormField.Option option : field.getOptions()) {
variable = option.getValue();
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
isByteStream = true;
}
@ -425,11 +421,9 @@ public class FileTransferNegotiator {
private StreamNegotiator getOutgoingNegotiator(final FormField field)
throws XMPPErrorException {
String variable;
boolean isByteStream = false;
boolean isIBB = false;
for (Iterator<String> it = field.getValues(); it.hasNext();) {
variable = it.next();
for (String variable : field.getValues()) {
if (variable.equals(Socks5BytestreamManager.NAMESPACE) && !IBB_ONLY) {
isByteStream = true;
}

View file

@ -19,8 +19,8 @@ package org.jivesoftware.smackx.iqprivate.packet;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
/**
* Default implementation of the PrivateData interface. Unless a PrivateDataProvider
@ -82,8 +82,7 @@ public class DefaultPrivateData implements PrivateData {
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">");
for (Iterator<String> i=getNames(); i.hasNext(); ) {
String name = i.next();
for (String name : getNames()) {
String value = getValue(name);
buf.append("<").append(name).append(">");
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.
*
* @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) {
return Collections.<String>emptyList().iterator();
return Collections.<String>emptySet();
}
return Collections.unmodifiableSet(map.keySet()).iterator();
return Collections.unmodifiableSet(map.keySet());
}
/**

View file

@ -23,7 +23,6 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
@ -129,9 +128,8 @@ public class MultiUserChat {
XMPPConnection connection = weakRefConnection.get();
if (connection == null) return new LinkedList<DiscoverItems.Item>();
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
Iterator<String> rooms=MultiUserChat.getJoinedRooms(connection);
while (rooms.hasNext()) {
answer.add(new DiscoverItems.Item(rooms.next()));
for (String room : MultiUserChat.getJoinedRooms(connection)) {
answer.add(new DiscoverItems.Item(room));
}
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
* (e.g. room@muc.jabber.org).
*
* @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);
if (rooms != null) {
return rooms.iterator();
return rooms;
}
// Return an iterator on an empty collection (i.e. the user never joined a room)
return new ArrayList<String>().iterator();
// Return an empty collection (i.e. the user never joined a room)
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).
*
* @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.
* @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 NoResponseException
* @throws NotConnectedException
*/
public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user)
public static List<String> getJoinedRooms(XMPPConnection connection, String user)
throws NoResponseException, XMPPErrorException, NotConnectedException {
ArrayList<String> answer = new ArrayList<String>();
// Send the disco packet to the user
@ -228,7 +226,7 @@ public class MultiUserChat {
for (DiscoverItems.Item item : result.getItems()) {
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
* 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() {
return Collections.unmodifiableList(new ArrayList<String>(occupantsMap.keySet()))
.iterator();
public List<String> getOccupants() {
return Collections.unmodifiableList(new ArrayList<String>(occupantsMap.keySet()));
}
/**
@ -1595,8 +1592,8 @@ public class MultiUserChat {
// Get the list of affiliates from the server's answer
List<Affiliate> affiliates = new ArrayList<Affiliate>();
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
affiliates.add(new Affiliate(it.next()));
for (MUCAdmin.Item mucadminItem : answer.getItems()) {
affiliates.add(new Affiliate(mucadminItem));
}
return affiliates;
}
@ -1646,8 +1643,8 @@ public class MultiUserChat {
MUCAdmin answer = (MUCAdmin) connection.createPacketCollectorAndSend(iq).nextResultOrThrow();
// Get the list of participants from the server's answer
List<Occupant> participants = new ArrayList<Occupant>();
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
participants.add(new Occupant(it.next()));
for (MUCAdmin.Item mucadminItem : answer.getItems()) {
participants.add(new Occupant(mucadminItem));
}
return participants;
}

View file

@ -85,14 +85,14 @@ public class RoomInfo {
Form form = Form.getFormFrom(info);
if (form != null) {
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");
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");
this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues()
.next());
.get(0));
}
}

View file

@ -17,8 +17,8 @@
package org.jivesoftware.smackx.muc.packet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.packet.IQ;
@ -36,15 +36,15 @@ public class MUCAdmin extends IQ {
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.
*
* @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.
*/
public Iterator<Item> getItems() {
public Collection<Item> getItems() {
synchronized (items) {
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
return Collections.unmodifiableList(new ArrayList<Item>(items));
}
}

View file

@ -19,8 +19,8 @@ package org.jivesoftware.smackx.muc.packet;
import org.jivesoftware.smack.packet.IQ;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
@ -36,15 +36,15 @@ public class MUCOwner extends IQ {
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.
*
* @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.
*/
public Iterator<Item> getItems() {
public Collection<Item> getItems() {
synchronized (items) {
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
return Collections.unmodifiableList(new ArrayList<Item>(items));
}
}

View file

@ -37,7 +37,6 @@ import org.jivesoftware.smackx.offline.packet.OfflineMessageRequest;
import org.jivesoftware.smackx.xdata.Form;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@ -99,49 +98,49 @@ public class OfflineMessageManager {
namespace);
Form extendedInfo = Form.getFormFrom(info);
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 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
* 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.
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Iterator<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException {
public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException {
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
null, namespace);
for (DiscoverItems.Item item : items.getItems()) {
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
* 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.
*
* @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.
* @throws XMPPErrorException If the user is not allowed to make this request or the server does
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @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>();
OfflineMessageRequest request = new OfflineMessageRequest();
for (String node : nodes) {
@ -169,7 +168,7 @@ public class OfflineMessageManager {
}
// Stop queuing offline messages
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)}
* 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
* not support offline message retrieval.
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
public Iterator<Message> getMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
public List<Message> getMessages() throws NoResponseException, XMPPErrorException, NotConnectedException {
List<Message> messages = new ArrayList<Message>();
OfflineMessageRequest request = new OfflineMessageRequest();
request.setFetch(true);
@ -200,7 +199,7 @@ public class OfflineMessageManager {
}
// Stop queuing offline messages
messageCollector.cancel();
return messages.iterator();
return messages;
}
/**

View file

@ -22,8 +22,8 @@ import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
@ -39,15 +39,15 @@ public class OfflineMessageRequest extends IQ {
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.
*
* @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.
*/
public Iterator<Item> getItems() {
public Collection<Item> getItems() {
synchronized (items) {
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
return Collections.unmodifiableList(new ArrayList<Item>(items));
}
}

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.pubsub;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
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).
*
* @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);
}
@ -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
* {@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);
}
@ -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
*/
public Iterator<String> getReplyRoom()
public List<String> getReplyRoom()
{
return getFieldValues(ConfigureNodeFields.replyroom);
}
@ -537,7 +536,7 @@ public class ConfigureForm extends Form
*
* @return The JID's
*/
public Iterator<String> getReplyTo()
public List<String> getReplyTo()
{
return getFieldValues(ConfigureNodeFields.replyto);
}
@ -558,7 +557,7 @@ public class ConfigureForm extends Form
*
* @return The roster groups
*/
public Iterator<String> getRosterGroupsAllowed()
public List<String> getRosterGroupsAllowed()
{
return getFieldValues(ConfigureNodeFields.roster_groups_allowed);
}
@ -642,23 +641,18 @@ public class ConfigureForm extends Form
{
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
Iterator<FormField> fields = getFields();
while (fields.hasNext())
for (FormField formField : getFields())
{
FormField formField = fields.next();
result.append('(');
result.append(formField.getVariable());
result.append(':');
Iterator<String> values = formField.getValues();
StringBuilder valuesBuilder = new StringBuilder();
while (values.hasNext())
for (String value : formField.getValues())
{
if (valuesBuilder.length() > 0)
result.append(',');
String value = (String)values.next();
valuesBuilder.append(value);
}
@ -680,10 +674,10 @@ public class ConfigureForm extends Form
{
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());

View file

@ -18,7 +18,6 @@ package org.jivesoftware.smackx.pubsub;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@ -450,14 +449,12 @@ abstract public class Node
else
{
ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
Collection<? extends PacketExtension> pubItems = itemsElem.getItems();
@SuppressWarnings("unchecked")
Iterator<RetractItem> it = (Iterator<RetractItem>)pubItems.iterator();
Collection<RetractItem> pubItems = (Collection<RetractItem>) itemsElem.getItems();
List<String> items = new ArrayList<String>(pubItems.size());
while (it.hasNext())
for (RetractItem item : pubItems)
{
RetractItem item = it.next();
items.add(item.getId());
}

View file

@ -135,7 +135,7 @@ final public class PubSubManager
FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
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

View file

@ -20,7 +20,7 @@ import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.UnknownFormatConversionException;
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
* 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);
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));
}
return result.iterator();
return result;
}
/**
@ -219,10 +217,10 @@ public class SubscribeForm extends Form
{
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());

View file

@ -24,7 +24,6 @@ import org.jivesoftware.smackx.xdata.packet.DataForm.Item;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
@ -67,22 +66,18 @@ public class ReportedData {
*/
private ReportedData(DataForm dataForm) {
// Add the columns to the report based on the reported data fields
for (Iterator<FormField> fields = dataForm.getReportedData().getFields(); fields.hasNext();) {
FormField field = fields.next();
for (FormField field : dataForm.getReportedData().getFields()) {
columns.add(new Column(field.getLabel(), field.getVariable(), field.getType()));
}
// Add the rows to the report based on the form's items
for (Iterator<Item> items = dataForm.getItems(); items.hasNext();) {
Item item = items.next();
for (Item item : dataForm.getItems()) {
List<Field> fieldList = new ArrayList<Field>(columns.size());
FormField field;
for (Iterator<FormField> fields = item.getFields(); fields.hasNext();) {
field = fields.next();
for (FormField field : item.getFields()) {
// The field is created with all the values of the data form's field
List<String> values = new ArrayList<String>();
for (Iterator<String> it=field.getValues(); it.hasNext();) {
values.add(it.next());
for (String value : field.getValues()) {
values.add(value);
}
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() {
return Collections.unmodifiableList(new ArrayList<Row>(rows)).iterator();
public List<Row> getRows() {
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() {
return Collections.unmodifiableList(new ArrayList<Column>(columns)).iterator();
public List<Column> getColumns() {
return Collections.unmodifiableList(new ArrayList<Column>(columns));
}
@ -229,9 +224,8 @@ public class ReportedData {
* @param variable the variable to match.
* @return the values of the field whose variable matches the requested variable.
*/
public Iterator<String> getValues(String variable) {
for(Iterator<Field> it=getFields();it.hasNext();) {
Field field = it.next();
public List<String> getValues(String variable) {
for(Field field : getFields()) {
if (variable.equalsIgnoreCase(field.getVariable())) {
return field.getValues();
}
@ -244,8 +238,8 @@ public class ReportedData {
*
* @return the fields that define the data that goes with the item.
*/
private Iterator<Field> getFields() {
return Collections.unmodifiableList(new ArrayList<Field>(fields)).iterator();
private List<Field> getFields() {
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.
*/
public Iterator<String> getValues() {
return Collections.unmodifiableList(values).iterator();
public List<String> getValues() {
return Collections.unmodifiableList(values);
}
}
}

View file

@ -22,7 +22,6 @@ import org.jivesoftware.smackx.xdata.FormField;
import org.xmlpull.v1.XmlPullParser;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@ -65,9 +64,7 @@ class SimpleUserSearch extends IQ {
return "";
}
Iterator<FormField> fields = form.getFields();
while (fields.hasNext()) {
FormField field = fields.next();
for (FormField field : form.getFields()) {
String name = field.getVariable();
String value = getSingleValue(field);
if (value.trim().length() > 0) {
@ -79,11 +76,12 @@ class SimpleUserSearch extends IQ {
}
private static String getSingleValue(FormField formField) {
Iterator<String> values = formField.getValues();
while (values.hasNext()) {
return values.next();
List<String> values = formField.getValues();
if (values.isEmpty()) {
return "";
} else {
return values.get(0);
}
return "";
}
protected void parseItems(XmlPullParser parser) throws Exception {
@ -121,11 +119,10 @@ class SimpleUserSearch extends IQ {
fields.add(field);
boolean exists = false;
Iterator<ReportedData.Column> cols = data.getColumns();
while (cols.hasNext()) {
ReportedData.Column column = cols.next();
for (ReportedData.Column column : data.getColumns()) {
if (column.getVariable().equals(name)) {
exists = true;
break;
}
}

View file

@ -21,7 +21,6 @@ import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
@ -49,8 +48,8 @@ public class SharedGroupsInfo extends IQ {
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();
buf.append("<sharedgroup xmlns=\"http://www.jivesoftware.org/protocol/sharedgroup\">");
for (Iterator<String> it=groups.iterator(); it.hasNext();) {
buf.append("<group>").append(it.next()).append("</group>");
for (String group : groups) {
buf.append("<group>").append(group).append("</group>");
}
buf.append("</sharedgroup>");
return buf.toString();

View file

@ -27,7 +27,6 @@ import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
@ -754,9 +753,7 @@ public class VCard extends IQ {
}
private void appendPhones(Map<String, String> phones, final String code) {
Iterator<Map.Entry<String, String>> it = phones.entrySet().iterator();
while (it.hasNext()) {
final Map.Entry<String,String> entry = it.next();
for (final Map.Entry<String,String> entry : phones.entrySet()) {
appendTag("TEL", true, new ContentBuilder() {
public void addTagContent() {
appendEmptyTag(entry.getKey());
@ -773,9 +770,7 @@ public class VCard extends IQ {
public void addTagContent() {
appendEmptyTag(code);
Iterator<Map.Entry<String, String>> it = addr.entrySet().iterator();
while (it.hasNext()) {
final Entry<String, String> entry = it.next();
for (final Entry<String, String> entry : addr.entrySet()) {
appendTag(entry.getKey(), StringUtils.escapeForXML(entry.getValue()));
}
}
@ -788,16 +783,12 @@ public class VCard extends IQ {
}
private void appendGenericFields() {
Iterator<Map.Entry<String, String>> it = otherSimpleFields.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
for (Map.Entry<String, String> entry : otherSimpleFields.entrySet()) {
appendTag(entry.getKey().toString(),
StringUtils.escapeForXML(entry.getValue()));
}
it = otherUnescapableFields.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> entry = it.next();
for (Map.Entry<String, String> entry : otherUnescapableFields.entrySet()) {
appendTag(entry.getKey().toString(),entry.getValue());
}
}

View file

@ -342,8 +342,8 @@ public class Form {
// Clear the old values
field.resetValues();
// Set the default value
for (Iterator<String> it = field.getValues(); it.hasNext();) {
field.addValue(it.next());
for (String value : field.getValues()) {
field.addValue(value);
}
}
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();
}
@ -373,9 +373,7 @@ public class Form {
throw new IllegalArgumentException("Variable must not be null or blank.");
}
// Look for the field whose variable matches the requested variable
FormField field;
for (Iterator<FormField> it=getFields();it.hasNext();) {
field = it.next();
for (FormField field : getFields()) {
if (variable.equals(field.getVariable())) {
return field;
}
@ -391,7 +389,7 @@ public class Form {
public String getInstructions() {
StringBuilder sb = new StringBuilder();
// 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());
// If this is not the last instruction then append a newline
if (it.hasNext()) {
@ -472,9 +470,8 @@ public class Form {
if (isSubmitType()) {
// Create a new DataForm that contains only the answered fields
DataForm dataFormToSend = new DataForm(getType());
for(Iterator<FormField> it=getFields();it.hasNext();) {
FormField field = it.next();
if (field.getValues().hasNext()) {
for(FormField field : getFields()) {
if (!field.getValues().isEmpty()) {
dataFormToSend.addField(field);
}
}
@ -521,8 +518,7 @@ public class Form {
}
// Create a new Form
Form form = new Form(TYPE_SUBMIT);
for (Iterator<FormField> fields=getFields(); fields.hasNext();) {
FormField field = fields.next();
for (FormField field : getFields()) {
// 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
if (field.getVariable() != null) {
@ -534,8 +530,8 @@ public class Form {
// Since a hidden field could have many values we need to collect them
// in a list
List<String> values = new ArrayList<String>();
for (Iterator<String> it=field.getValues();it.hasNext();) {
values.add(it.next());
for (String value : field.getValues()) {
values.add(value);
}
form.setAnswer(field.getVariable(), values);
}

View file

@ -22,7 +22,6 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
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.
*
* @return Iterator for the available options.
* @return List of the available options.
*/
public Iterator<Option> getOptions() {
public List<Option> getOptions() {
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
* of a form to fill out. Otherwise, returns an Iterator for the answered values of
* Returns a List of the default values of the question if the question is part
* of a form to fill out. Otherwise, returns a List of the answered values of
* 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) {
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/>");
}
// Loop through all the values and append them to the string buffer
for (Iterator<String> i = getValues(); i.hasNext();) {
buf.element("value", i.next());
for (String value : getValues()) {
buf.element("value", value);
}
// Loop through all the values and append them to the string buffer
for (Iterator<Option> i = getOptions(); i.hasNext();) {
buf.append((i.next()).toXML());
for (Option option : getOptions()) {
buf.append(option.toXML());
}
buf.append("</field>");
return buf.toString();

View file

@ -23,7 +23,6 @@ import org.jivesoftware.smackx.xdata.FormField;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
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
* instruction could not contain newlines characters. Join the instructions together in order
* 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) {
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) {
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) {
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) {
buf.append("<title>").append(getTitle()).append("</title>");
}
for (Iterator<String> it=getInstructions(); it.hasNext();) {
buf.append("<instructions>").append(it.next()).append("</instructions>");
for (String instruction : getInstructions()) {
buf.append("<instructions>").append(instruction).append("</instructions>");
}
// Append the list of fields returned from a search
if (getReportedData() != null) {
buf.append(getReportedData().toXML());
}
// Loop through all the items returned from a search and append them to the string buffer
for (Iterator<Item> i = getItems(); i.hasNext();) {
Item item = i.next();
for (Item item : getItems()) {
buf.append(item.toXML());
}
// Loop through all the form fields and append them to the string buffer
for (Iterator<FormField> i = getFields(); i.hasNext();) {
FormField field = i.next();
for (FormField field : getFields()) {
buf.append(field.toXML());
}
buf.append("</").append(getElementName()).append(">");
@ -255,16 +252,15 @@ public class DataForm implements PacketExtension {
*
* @return the fields returned from a search.
*/
public Iterator<FormField> getFields() {
return Collections.unmodifiableList(new ArrayList<FormField>(fields)).iterator();
public List<FormField> getFields() {
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<reported>");
// Loop through all the form items and append them to the string buffer
for (Iterator<FormField> i = getFields(); i.hasNext();) {
FormField field = i.next();
for (FormField field : getFields()) {
buf.append(field.toXML());
}
buf.append("</reported>");
@ -290,16 +286,15 @@ public class DataForm implements PacketExtension {
*
* @return the fields that define the data that goes with the item.
*/
public Iterator<FormField> getFields() {
return Collections.unmodifiableList(new ArrayList<FormField>(fields)).iterator();
public List<FormField> getFields() {
return Collections.unmodifiableList(new ArrayList<FormField>(fields));
}
public String toXML() {
StringBuilder buf = new StringBuilder();
buf.append("<item>");
// Loop through all the form items and append them to the string buffer
for (Iterator<FormField> i = getFields(); i.hasNext();) {
FormField field = i.next();
for (FormField field : getFields()) {
buf.append(field.toXML());
}
buf.append("</item>");

View file

@ -19,7 +19,6 @@ package org.jivesoftware.smackx.xevent;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -198,18 +197,18 @@ public class MessageEventManager {
(MessageEvent) message.getExtension("x", "jabber:x:event");
if (messageEvent.isMessageEventRequest()) {
// Fire event for requests of message events
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
for (String eventType : messageEvent.getEventTypes())
fireMessageEventRequestListeners(
message.getFrom(),
message.getPacketID(),
it.next().concat("NotificationRequested"));
eventType.concat("NotificationRequested"));
} else
// Fire event for notifications of message events
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
for (String eventType : messageEvent.getEventTypes())
fireMessageEventNotificationListeners(
message.getFrom(),
messageEvent.getPacketID(),
it.next().concat("Notification"));
eventType.concat("Notification"));
};

View file

@ -20,7 +20,7 @@ package org.jivesoftware.smackx.xevent.packet;
import org.jivesoftware.smack.packet.PacketExtension;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 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:
* "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>();
if (isDelivered()) {
allEvents.add(MessageEvent.DELIVERED);
@ -181,7 +181,7 @@ public class MessageEvent implements PacketExtension {
if (isOffline()) {
allEvents.add(MessageEvent.OFFLINE);
}
return allEvents.iterator();
return allEvents;
}
/**

View file

@ -26,7 +26,7 @@ import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
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
@ -55,7 +55,7 @@ public class XHTMLManager {
* @param message an XHTML message
* @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);
if (xhtmlExtension != null)
return xhtmlExtension.getBodies();

View file

@ -21,7 +21,6 @@ import org.jivesoftware.smack.packet.PacketExtension;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
@ -82,21 +81,21 @@ public class XHTMLExtension implements PacketExtension {
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
"\">");
// Loop through all the bodies and append them to the string buffer
for (Iterator<String> i = getBodies(); i.hasNext();) {
buf.append(i.next());
for (String body : getBodies()) {
buf.append(body);
}
buf.append("</").append(getElementName()).append(">");
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) {
return Collections.unmodifiableList(new ArrayList<String>(bodies)).iterator();
return Collections.unmodifiableList(new ArrayList<String>(bodies));
}
}

View file

@ -47,7 +47,7 @@ public class XHTMLExtensionProviderTest {
assertThat(extension, is(instanceOf(XHTMLExtension.class)));
XHTMLExtension attachmentsInfo = (XHTMLExtension) extension;
assertEquals(sampleXhtml(), attachmentsInfo.getBodies().next());
assertEquals(sampleXhtml(), attachmentsInfo.getBodies().get(0));
}
private String sampleXhtml() {