Commit f49deabc authored by Matt Tucker's avatar Matt Tucker Committed by matt

Concurrency (JM-554).

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3385 b35dd754-fafc-0310-a699-88a17e54d16e
parent af42ba45
...@@ -18,15 +18,13 @@ import java.util.AbstractCollection; ...@@ -18,15 +18,13 @@ import java.util.AbstractCollection;
/** /**
* Provides a view of an array of usernames as a Collection of User objects. If * Provides a view of an array of usernames as a Collection of User objects. If
* any of the usernames cannot be loaded, they are transparently skipped when * any of the usernames cannot be loaded, they are transparently skipped when
* iteratating over the collection. * iterating over the collection.
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
public class UserCollection extends AbstractCollection { public class UserCollection extends AbstractCollection {
private String[] elements; private String[] elements;
private int currentIndex = -1;
private Object nextElement = null;
/** /**
* Constructs a new UserIterator. * Constructs a new UserIterator.
...@@ -45,6 +43,9 @@ public class UserCollection extends AbstractCollection { ...@@ -45,6 +43,9 @@ public class UserCollection extends AbstractCollection {
private class UserIterator implements Iterator { private class UserIterator implements Iterator {
private int currentIndex = -1;
private Object nextElement = null;
public boolean hasNext() { public boolean hasNext() {
// If we are at the end of the list, there can't be any more elements // If we are at the end of the list, there can't be any more elements
// to iterate through. // to iterate through.
...@@ -63,7 +64,7 @@ public class UserCollection extends AbstractCollection { ...@@ -63,7 +64,7 @@ public class UserCollection extends AbstractCollection {
} }
public Object next() throws java.util.NoSuchElementException { public Object next() throws java.util.NoSuchElementException {
Object element = null; Object element;
if (nextElement != null) { if (nextElement != null) {
element = nextElement; element = nextElement;
nextElement = null; nextElement = null;
...@@ -93,7 +94,9 @@ public class UserCollection extends AbstractCollection { ...@@ -93,7 +94,9 @@ public class UserCollection extends AbstractCollection {
try { try {
element = UserManager.getInstance().getUser(elements[currentIndex]); element = UserManager.getInstance().getUser(elements[currentIndex]);
} }
catch (UserNotFoundException unfe) { } catch (UserNotFoundException unfe) {
// Ignore.
}
if (element != null) { if (element != null) {
return element; return element;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment