Revision: 2640
http://archive-access.svn.sourceforge.net/archive-access/?rev=2640&view=rev
Author: bradtofel
Date: 2008-11-07 22:40:02 +0000 (Fri, 07 Nov 2008)
Log Message:
-----------
INITIAL REV: CaptureSearchResult ObjectFilter that only includes results matching the specified scheme.
Added Paths:
-----------
trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/SchemeMatchFilter.java
Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/SchemeMatchFilter.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/SchemeMatchFilter.java (rev 0)
+++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/SchemeMatchFilter.java 2008-11-07 22:40:02 UTC (rev 2640)
@@ -0,0 +1,60 @@
+/* SchemeMatchFilter
+ *
+ * $Id$
+ *
+ * Created on 6:40:02 PM Nov 6, 2008.
+ *
+ * Copyright (C) 2008 Internet Archive.
+ *
+ * This file is part of wayback.
+ *
+ * wayback is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * any later version.
+ *
+ * wayback 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser Public License
+ * along with wayback; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package org.archive.wayback.resourceindex.filters;
+
+import org.archive.wayback.core.CaptureSearchResult;
+import org.archive.wayback.util.ObjectFilter;
+import org.archive.wayback.util.url.UrlOperations;
+
+/**
+ * ObjectFilter which omits CaptureSearchResult objects if their scheme does not
+ * match the specified scheme.
+ *
+ * @author brad
+ * @version $Date$, $Revision$
+ */
+
+public class SchemeMatchFilter implements ObjectFilter<CaptureSearchResult> {
+
+ private String scheme = null;
+
+ /**
+ * @param hostname String of original host to match
+ */
+ public SchemeMatchFilter(final String scheme) {
+ this.scheme = scheme;
+ }
+
+ /* (non-Javadoc)
+ * @see org.archive.wayback.util.ObjectFilter#filterObject(java.lang.Object)
+ */
+ public int filterObject(CaptureSearchResult r) {
+ String captureScheme = UrlOperations.urlToScheme(r.getOriginalUrl());
+ if(scheme == null) {
+ return captureScheme == null ? FILTER_INCLUDE : FILTER_EXCLUDE;
+ }
+ return scheme.equals(captureScheme) ? FILTER_INCLUDE : FILTER_EXCLUDE;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|