Revision: 1778 http://archive-access.svn.sourceforge.net/archive-access/?rev=1778&view=rev Author: bradtofel Date: 2007-07-16 15:53:22 -0700 (Mon, 16 Jul 2007) Log Message: ----------- INITIAL REV: awful filter that translates CaptureSearchResults to URLSearchResults, breaking encapsulation completely. Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java 2007-07-16 22:53:22 UTC (rev 1778) @@ -0,0 +1,102 @@ +/* CaptureToUrlResultFilter + * + * $Id$ + * + * Created on 6:23:07 PM Apr 19, 2007. + * + * Copyright (C) 2007 Internet Archive. + * + * This file is part of wayback-core. + * + * wayback-core 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-core 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-core; 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 java.util.HashMap; +import java.util.Properties; + +import org.archive.wayback.WaybackConstants; +import org.archive.wayback.core.SearchResult; +import org.archive.wayback.resourceindex.SearchResultFilter; + +/** + * + * + * @author brad + * @version $Date$, $Revision$ + */ +public class CaptureToUrlResultFilter extends SearchResultFilter { + private String currentUrl; + private String firstCapture; + private String lastCapture; + private int numCaptures; + private HashMap<String,Object> digests; + private SearchResult resultRef = null; + + private final static String RESULT_URL = "result.url"; + private final static String RESULT_FIRST_CAPTURE = "result.firstcapture"; + private final static String RESULT_LAST_CAPTURE = "result.lastcapture"; + private final static String RESULT_NUM_CAPTURES = "result.numcaptures"; + private final static String RESULT_NUM_VERSIONS = "result.numversions"; + private final static String RESULT_ORIGINAL_URL = "result.originalurl"; + + private void fungeSearchResult(SearchResult result) { + String originalUrl = result.get(WaybackConstants.RESULT_URL); + currentUrl = result.get(WaybackConstants.RESULT_URL_KEY); + firstCapture = result.get(WaybackConstants.RESULT_CAPTURE_DATE); + lastCapture = result.get(WaybackConstants.RESULT_CAPTURE_DATE); + digests = new HashMap<String,Object>(); + digests.put(result.get(WaybackConstants.RESULT_MD5_DIGEST),null); + numCaptures = 1; + + Properties p = result.getData(); + p.clear(); + resultRef = result; + resultRef.put(RESULT_ORIGINAL_URL,originalUrl); + resultRef.put(RESULT_URL,currentUrl); + resultRef.put(RESULT_FIRST_CAPTURE,firstCapture); + resultRef.put(RESULT_LAST_CAPTURE,firstCapture); + resultRef.put(RESULT_NUM_CAPTURES,"1"); + resultRef.put(RESULT_NUM_VERSIONS,"1"); + } + /* (non-Javadoc) + * @see org.archive.wayback.resourceindex.SearchResultFilter#filterSearchResult(org.archive.wayback.core.SearchResult) + */ + @Override + public int filterSearchResult(SearchResult r) { + String urlKey = r.get(WaybackConstants.RESULT_URL_KEY); + if(resultRef == null || !currentUrl.equals(urlKey)) { + fungeSearchResult(r); + return FILTER_INCLUDE; + } + + // same url -- accumulate: + String captureDate = r.get(WaybackConstants.RESULT_CAPTURE_DATE); + if(captureDate.compareTo(firstCapture) < 0) { + firstCapture = captureDate; + resultRef.put(RESULT_FIRST_CAPTURE,firstCapture); + } + if(captureDate.compareTo(lastCapture) < 0) { + lastCapture = captureDate; + resultRef.put(RESULT_LAST_CAPTURE,lastCapture); + } + numCaptures++; + digests.put(r.get(WaybackConstants.RESULT_MD5_DIGEST), null); + resultRef.put(RESULT_NUM_CAPTURES,String.valueOf(numCaptures)); + resultRef.put(RESULT_NUM_VERSIONS,String.valueOf(digests.size())); + return FILTER_EXCLUDE; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 1814 http://archive-access.svn.sourceforge.net/archive-access/?rev=1814&view=rev Author: bradtofel Date: 2007-07-19 13:50:30 -0700 (Thu, 19 Jul 2007) Log Message: ----------- TWEAK: empty comments... These need to move to WaybackConstants. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java 2007-07-19 20:49:38 UTC (rev 1813) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java 2007-07-19 20:50:30 UTC (rev 1814) @@ -45,12 +45,30 @@ private HashMap<String,Object> digests; private SearchResult resultRef = null; - private final static String RESULT_URL = "result.url"; - private final static String RESULT_FIRST_CAPTURE = "result.firstcapture"; - private final static String RESULT_LAST_CAPTURE = "result.lastcapture"; - private final static String RESULT_NUM_CAPTURES = "result.numcaptures"; - private final static String RESULT_NUM_VERSIONS = "result.numversions"; - private final static String RESULT_ORIGINAL_URL = "result.originalurl"; + /** + * + */ + public final static String RESULT_URL = "result.url"; + /** + * + */ + public final static String RESULT_FIRST_CAPTURE = "result.firstcapture"; + /** + * + */ + public final static String RESULT_LAST_CAPTURE = "result.lastcapture"; + /** + * + */ + public final static String RESULT_NUM_CAPTURES = "result.numcaptures"; + /** + * + */ + public final static String RESULT_NUM_VERSIONS = "result.numversions"; + /** + * + */ + public final static String RESULT_ORIGINAL_URL = "result.originalurl"; private void fungeSearchResult(SearchResult result) { String originalUrl = result.get(WaybackConstants.RESULT_URL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 1908 http://archive-access.svn.sourceforge.net/archive-access/?rev=1908&view=rev Author: bradtofel Date: 2007-08-17 17:58:34 -0700 (Fri, 17 Aug 2007) Log Message: ----------- BUGFIX: (unreported) bad logic for tracking last date fixed -- was not updating correctly, so always indicated last date being the same as the first date. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java 2007-08-18 00:56:22 UTC (rev 1907) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java 2007-08-18 00:58:34 UTC (rev 1908) @@ -85,7 +85,7 @@ resultRef.put(RESULT_ORIGINAL_URL,originalUrl); resultRef.put(RESULT_URL,currentUrl); resultRef.put(RESULT_FIRST_CAPTURE,firstCapture); - resultRef.put(RESULT_LAST_CAPTURE,firstCapture); + resultRef.put(RESULT_LAST_CAPTURE,lastCapture); resultRef.put(RESULT_NUM_CAPTURES,"1"); resultRef.put(RESULT_NUM_VERSIONS,"1"); } @@ -103,7 +103,7 @@ firstCapture = captureDate; resultRef.put(RESULT_FIRST_CAPTURE,firstCapture); } - if(captureDate.compareTo(lastCapture) < 0) { + if(captureDate.compareTo(lastCapture) > 0) { lastCapture = captureDate; resultRef.put(RESULT_LAST_CAPTURE,lastCapture); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 2383 http://archive-access.svn.sourceforge.net/archive-access/?rev=2383&view=rev Author: bradtofel Date: 2008-07-01 16:56:58 -0700 (Tue, 01 Jul 2008) Log Message: ----------- REFACTOR: replaced with adapter. Removed Paths: ------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java Deleted: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java 2008-07-01 23:56:23 UTC (rev 2382) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourceindex/filters/CaptureToUrlResultFilter.java 2008-07-01 23:56:58 UTC (rev 2383) @@ -1,117 +0,0 @@ -/* CaptureToUrlResultFilter - * - * $Id$ - * - * Created on 6:23:07 PM Apr 19, 2007. - * - * Copyright (C) 2007 Internet Archive. - * - * This file is part of wayback-core. - * - * wayback-core 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-core 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-core; 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 java.util.HashMap; -import java.util.Properties; - -import org.archive.wayback.WaybackConstants; -import org.archive.wayback.core.SearchResult; -import org.archive.wayback.util.ObjectFilter; - -/** - * - * - * @author brad - * @version $Date$, $Revision$ - */ -public class CaptureToUrlResultFilter implements ObjectFilter<SearchResult> { - private String currentUrl; - private String firstCapture; - private String lastCapture; - private int numCaptures; - private HashMap<String,Object> digests; - private SearchResult resultRef = null; - - /** - * - */ - public final static String RESULT_URL = "result.url"; - /** - * - */ - public final static String RESULT_FIRST_CAPTURE = "result.firstcapture"; - /** - * - */ - public final static String RESULT_LAST_CAPTURE = "result.lastcapture"; - /** - * - */ - public final static String RESULT_NUM_CAPTURES = "result.numcaptures"; - /** - * - */ - public final static String RESULT_NUM_VERSIONS = "result.numversions"; - /** - * - */ - public final static String RESULT_ORIGINAL_URL = "result.originalurl"; - - private void fungeSearchResult(SearchResult result) { - String originalUrl = result.get(WaybackConstants.RESULT_URL); - currentUrl = result.get(WaybackConstants.RESULT_URL_KEY); - firstCapture = result.get(WaybackConstants.RESULT_CAPTURE_DATE); - lastCapture = result.get(WaybackConstants.RESULT_CAPTURE_DATE); - digests = new HashMap<String,Object>(); - digests.put(result.get(WaybackConstants.RESULT_MD5_DIGEST),null); - numCaptures = 1; - - Properties p = result.getData(); - p.clear(); - resultRef = result; - resultRef.put(RESULT_ORIGINAL_URL,originalUrl); - resultRef.put(RESULT_URL,currentUrl); - resultRef.put(RESULT_FIRST_CAPTURE,firstCapture); - resultRef.put(RESULT_LAST_CAPTURE,lastCapture); - resultRef.put(RESULT_NUM_CAPTURES,"1"); - resultRef.put(RESULT_NUM_VERSIONS,"1"); - } - - public int filterObject(SearchResult r) { - String urlKey = r.get(WaybackConstants.RESULT_URL_KEY); - if(resultRef == null || !currentUrl.equals(urlKey)) { - fungeSearchResult(r); - return FILTER_INCLUDE; - } - - // same url -- accumulate: - String captureDate = r.get(WaybackConstants.RESULT_CAPTURE_DATE); - if(captureDate.compareTo(firstCapture) < 0) { - firstCapture = captureDate; - resultRef.put(RESULT_FIRST_CAPTURE,firstCapture); - } - if(captureDate.compareTo(lastCapture) > 0) { - lastCapture = captureDate; - resultRef.put(RESULT_LAST_CAPTURE,lastCapture); - } - numCaptures++; - digests.put(r.get(WaybackConstants.RESULT_MD5_DIGEST), null); - resultRef.put(RESULT_NUM_CAPTURES,String.valueOf(numCaptures)); - resultRef.put(RESULT_NUM_VERSIONS,String.valueOf(digests.size())); - return FILTER_EXCLUDE; - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |