org.datacleaner.storage.BerkeleyDbSet Maven / Gradle / Ivy
/**
* DataCleaner (community edition)
* Copyright (C) 2014 Neopost - Customer Information Management
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program 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 distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.datacleaner.storage;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import com.sleepycat.collections.StoredKeySet;
import com.sleepycat.je.Database;
import com.sleepycat.je.Environment;
final class BerkeleyDbSet implements Set {
private final Set _wrappedSet;
private final Environment _environment;
private final Database _database;
@SuppressWarnings("unchecked")
public BerkeleyDbSet(final Environment environment, final Database database, final StoredKeySet set) {
_environment = environment;
_database = database;
_wrappedSet = set;
}
public Set getWrappedSet() {
return _wrappedSet;
}
@Override
protected void finalize() throws Throwable {
super.finalize();
final String name = _database.getDatabaseName();
_database.close();
_environment.removeDatabase(null, name);
}
public int size() {
return _wrappedSet.size();
}
public boolean isEmpty() {
return _wrappedSet.isEmpty();
}
public boolean contains(final Object o) {
return _wrappedSet.contains(o);
}
public Iterator iterator() {
return _wrappedSet.iterator();
}
public Object[] toArray() {
return _wrappedSet.toArray();
}
public T[] toArray(final T[] a) {
return _wrappedSet.toArray(a);
}
public boolean add(final E e) {
return _wrappedSet.add(e);
}
public boolean remove(final Object o) {
return _wrappedSet.remove(o);
}
public boolean containsAll(final Collection> c) {
return _wrappedSet.containsAll(c);
}
public boolean addAll(final Collection extends E> c) {
return _wrappedSet.addAll(c);
}
public boolean retainAll(final Collection> c) {
return _wrappedSet.retainAll(c);
}
public boolean removeAll(final Collection> c) {
return _wrappedSet.removeAll(c);
}
public void clear() {
_wrappedSet.clear();
}
public boolean equals(final Object o) {
return _wrappedSet.equals(o);
}
public int hashCode() {
return _wrappedSet.hashCode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy