io.leopard.web.session.Enumerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leopard-session Show documentation
Show all versions of leopard-session Show documentation
分布式session实现。基于Leopard Memcache接口实现,目前Leopard已实现基于Memcached、Redis两种实现。
package io.leopard.web.session;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
public class Enumerator implements Enumeration {
public Enumerator(Collection collection) {
this(collection.iterator());
}
public Enumerator(Collection collection, boolean clone) {
this(collection.iterator(), clone);
}
public Enumerator(Iterator iterator) {
super();
this.iterator = iterator;
}
public Enumerator(Iterator iterator, boolean clone) {
super();
if (!clone) {
this.iterator = iterator;
}
else {
List list = new ArrayList();
while (iterator.hasNext()) {
list.add(iterator.next());
}
this.iterator = list.iterator();
}
}
private Iterator iterator = null;
public boolean hasMoreElements() {
return (iterator.hasNext());
}
public String nextElement() throws NoSuchElementException {
return (iterator.next());
}
}