1 /* Copyright (C) 2003 Internet Archive. 2 * 3 * This file is part of the Heritrix web crawler (crawler.archive.org). 4 * 5 * Heritrix is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser Public License as published by 7 * the Free Software Foundation; either version 2.1 of the License, or 8 * any later version. 9 * 10 * Heritrix is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser Public License 16 * along with Heritrix; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * MemUURISet.java 20 * Created on Sep 15, 2003 21 * 22 * $Header$ 23 */ 24 package org.archive.crawler.util; 25 26 import java.util.HashSet; 27 28 /*** 29 * A purely in-memory UriUniqFilter based on a HashSet, which remembers 30 * every full URI string it sees. 31 * 32 * @author gojomo 33 * 34 */ 35 public class MemUriUniqFilter 36 extends SetBasedUriUniqFilter { 37 HashSet<CharSequence> hashSet; 38 39 protected synchronized boolean setAdd(CharSequence uri) { 40 return hashSet.add(uri); 41 } 42 protected synchronized boolean setRemove(CharSequence uri) { 43 return hashSet.remove(uri); 44 } 45 protected synchronized long setCount() { 46 return (long)hashSet.size(); 47 } 48 49 /* (non-Javadoc) 50 * @see org.archive.crawler.util.UriUniqFilterImpl#createUriSet() 51 */ 52 protected void createUriSet() { 53 hashSet = new HashSet<CharSequence>(); 54 } 55 56 }