net.smartlab.web.page.CollectionPaginator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smartweb Show documentation
Show all versions of smartweb Show documentation
SmartWeb is a web application development meta framework based on Jakarta Struts, Hibernate and other open source frameworks and libraries.
/*
* The SmartWeb Framework
* Copyright (C) 2004-2006
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* For further informations on the SmartWeb Framework please visit
*
* http://smartweb.sourceforge.net
*/
package net.smartlab.web.page;
import java.util.Collection;
import java.util.Iterator;
/**
* TODO documentation
*
* @author rlogiacco
*/
public class CollectionPaginator extends Paginator implements Collection {
private Collection collection;
/**
* TODO documentation
*
* @param collection
*/
public CollectionPaginator(Collection collection) {
this(collection, 0);
}
/**
* TODO documentation
*
* @param collection
* @param size
*/
public CollectionPaginator(Collection collection, int size) {
this(collection, size, Paginator.UNLIMITED_PAGES);
}
/**
* TODO documentation
*
* @param collection
* @param size
* @param pages
*/
public CollectionPaginator(Collection collection, int size, int pages) {
super(size, pages);
super.setCount(collection.size());
this.collection = collection;
}
/**
* @see net.smartlab.web.Paginator#setArray()
*/
protected void setArray() {
Object[] temp = collection.toArray();
try {
java.lang.System.arraycopy(temp, (super.getPage() - 1) * array.length, array, 0, array.length);
} catch (IndexOutOfBoundsException ioobe) {
java.lang.System.arraycopy(temp, (super.getPage() - 1) * array.length, array, 0, collection.size() % array.length);
array[collection.size() % array.length] = null;
}
}
/**
* @see java.util.Collection#size()
*/
public int size() {
return collection.size();
}
/**
* @see java.util.Collection#clear()
*/
public void clear() {
collection.clear();
}
/**
* @see java.util.Collection#isEmpty()
*/
public boolean isEmpty() {
return collection.isEmpty();
}
/**
* @see java.util.Collection#toArray()
*/
public Object[] toArray() {
return this.array;
}
/**
* @see java.util.Collection#add(java.lang.Object)
*/
public boolean add(Object o) {
return collection.add(o);
}
/**
* @see java.util.Collection#contains(java.lang.Object)
*/
public boolean contains(Object o) {
return collection.contains(o);
}
/**
* @see java.util.Collection#remove(java.lang.Object)
*/
public boolean remove(Object o) {
return collection.remove(o);
}
/**
* @see java.util.Collection#addAll(java.util.Collection)
*/
public boolean addAll(Collection c) {
return collection.addAll(c);
}
/**
* @see java.util.Collection#containsAll(java.util.Collection)
*/
public boolean containsAll(Collection c) {
return collection.containsAll(c);
}
/**
* @see java.util.Collection#removeAll(java.util.Collection)
*/
public boolean removeAll(Collection c) {
return collection.removeAll(c);
}
/**
* @see java.util.Collection#retainAll(java.util.Collection)
*/
public boolean retainAll(Collection c) {
return collection.retainAll(c);
}
/**
* @see java.util.Collection#iterator()
*/
public Iterator iterator() {
return this;
}
/**
* @see java.util.Collection#toArray(java.lang.Object[])
*/
public Object[] toArray(Object[] a) {
throw new UnsupportedOperationException();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy