From: <bra...@us...> - 2007-07-16 22:32:44
|
Revision: 1771 http://archive-access.svn.sourceforge.net/archive-access/?rev=1771&view=rev Author: bradtofel Date: 2007-07-16 15:32:47 -0700 (Mon, 16 Jul 2007) Log Message: ----------- INITIAL REV: possibly transient explicit separation of search result types: url and capture Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java 2007-07-16 22:32:47 UTC (rev 1771) @@ -0,0 +1,97 @@ +/* CaptureSearchResults + * + * $Id$ + * + * Created on 4:05:33 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.core; + +import java.text.ParseException; +import java.util.Iterator; + +import org.archive.wayback.WaybackConstants; + +/** + * + * + * @author brad + * @version $Date$, $Revision$ + */ +public class CaptureSearchResults extends SearchResults { + public String getResultsType() { + return WaybackConstants.RESULTS_TYPE_CAPTURE; + } + /** + * append a result + * @param result + */ + public void addSearchResult(final SearchResult result) { + addSearchResult(result,true); + } + /** + * add a result to this results, at either the begginning or at the end, + * depending on the append argument + * @param result + * SearchResult to add to this set + * @param append + */ + public void addSearchResult(final SearchResult result, final boolean append) { + String resultDate = result.get(WaybackConstants.RESULT_CAPTURE_DATE); + if((firstResultDate == null) || + (firstResultDate.compareTo(resultDate) > 0)) { + firstResultDate = resultDate; + } + if((lastResultDate == null) || + (lastResultDate.compareTo(resultDate) < 0)) { + lastResultDate = resultDate; + } + addSearchResultRaw(result,append); + } + /** + * @param wbRequest + * @return The closest SearchResult to the request. + * @throws ParseException + */ + public SearchResult getClosest(WaybackRequest wbRequest) { + + SearchResult closest = null; + long closestDistance = 0; + SearchResult cur = null; + Timestamp wantTimestamp; + wantTimestamp = Timestamp.parseBefore(wbRequest + .get(WaybackConstants.REQUEST_EXACT_DATE)); + + Iterator itr = results.iterator(); + while (itr.hasNext()) { + cur = (SearchResult) itr.next(); + long curDistance; + Timestamp curTimestamp = Timestamp.parseBefore(cur + .get(WaybackConstants.RESULT_CAPTURE_DATE)); + curDistance = curTimestamp.absDistanceFromTimestamp(wantTimestamp); + + if ((closest == null) || (curDistance < closestDistance)) { + closest = cur; + closestDistance = curDistance; + } + } + return closest; + } +} Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java 2007-07-16 22:30:57 UTC (rev 1770) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java 2007-07-16 22:32:47 UTC (rev 1771) @@ -24,32 +24,29 @@ */ package org.archive.wayback.core; -import java.text.ParseException; import java.util.ArrayList; import java.util.Iterator; import java.util.Properties; -import org.archive.wayback.WaybackConstants; - /** * * * @author brad * @version $Date$, $Revision$ */ -public class SearchResults { +public abstract class SearchResults { /** * List of SearchResult objects for index records matching a query */ - private ArrayList<SearchResult> results = null; + protected ArrayList<SearchResult> results = null; /** * 14-digit timestamp of first capture date contained in the SearchResults */ - private String firstResultDate; + protected String firstResultDate; /** * 14-digit timestamp of last capture date contained in the SearchResults */ - private String lastResultDate; + protected String lastResultDate; /** * Expandable data bag for tuples associated with the search results, * likely examples might be "total matching documents", "index of first @@ -72,35 +69,39 @@ } /** - * append a result * @param result + * @param append */ - public void addSearchResult(final SearchResult result) { - addSearchResult(result,true); + public void addSearchResultRaw(final SearchResult result, + final boolean append) { + + if(append) { + results.add(result); + } else { + results.add(0,result); + } } + /** + * @return one of "Url" or "Capture" depending on the type of results + * contained in this object + */ + public abstract String getResultsType(); + + /** + * append a result + * @param result + */ + public abstract void addSearchResult(final SearchResult result); + /** * add a result to this results, at either the begginning or at the end, * depending on the append argument * @param result * SearchResult to add to this set * @param append */ - public void addSearchResult(final SearchResult result, final boolean append) { - String resultDate = result.get(WaybackConstants.RESULT_CAPTURE_DATE); - if((firstResultDate == null) || - (firstResultDate.compareTo(resultDate) > 0)) { - firstResultDate = resultDate; - } - if((lastResultDate == null) || - (lastResultDate.compareTo(resultDate) < 0)) { - lastResultDate = resultDate; - } - if(append) { - results.add(result); - } else { - results.add(0,result); - } - } + public abstract void addSearchResult(final SearchResult result, + final boolean append); /** * @return number of SearchResult objects contained in these SearchResults @@ -158,33 +159,4 @@ public Properties getFilters() { return filters; } - /** - * @param wbRequest - * @return The closest SearchResult to the request. - * @throws ParseException - */ - public SearchResult getClosest(WaybackRequest wbRequest) { - - SearchResult closest = null; - long closestDistance = 0; - SearchResult cur = null; - Timestamp wantTimestamp; - wantTimestamp = Timestamp.parseBefore(wbRequest - .get(WaybackConstants.REQUEST_EXACT_DATE)); - - Iterator itr = results.iterator(); - while (itr.hasNext()) { - cur = (SearchResult) itr.next(); - long curDistance; - Timestamp curTimestamp = Timestamp.parseBefore(cur - .get(WaybackConstants.RESULT_CAPTURE_DATE)); - curDistance = curTimestamp.absDistanceFromTimestamp(wantTimestamp); - - if ((closest == null) || (curDistance < closestDistance)) { - closest = cur; - closestDistance = curDistance; - } - } - return closest; - } } Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java 2007-07-16 22:32:47 UTC (rev 1771) @@ -0,0 +1,58 @@ +/* UrlSearchResults + * + * $Id$ + * + * Created on 4:06:03 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.core; + +import org.archive.wayback.WaybackConstants; + +/** + * + * + * @author brad + * @version $Date$, $Revision$ + */ +public class UrlSearchResults extends SearchResults { + private UrlSearchResultAccumulator accumulator = null; + + public String getResultsType() { + return WaybackConstants.RESULTS_TYPE_URL; + } + public void addSearchResult(SearchResult result) { + addSearchResult(result,true); + } + + /* (non-Javadoc) + * @see org.archive.wayback.core.SearchResults#addSearchResult(org.archive.wayback.core.SearchResult, boolean) + */ + @Override + public void addSearchResult(SearchResult result, boolean append) { + addSearchResultRaw(result,append); +// if(accumulator != null && accumulator.sameUrl(result)) { +// accumulator.addSearchResult(result); +// } else { +// accumulator = new UrlSearchResultAccumulator(result); +// addSearchResultRaw(accumulator.getResult(),append); +// } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2007-07-20 01:25:28
|
Revision: 1851 http://archive-access.svn.sourceforge.net/archive-access/?rev=1851&view=rev Author: bradtofel Date: 2007-07-19 18:25:30 -0700 (Thu, 19 Jul 2007) Log Message: ----------- REFACTOR: now replaced by Spring and org.archive.wayback.webapp.ServletRequestContext. woot! Removed Paths: ------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackLogic.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackServlet.java Deleted: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackLogic.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackLogic.java 2007-07-20 01:24:30 UTC (rev 1850) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackLogic.java 2007-07-20 01:25:30 UTC (rev 1851) @@ -1,242 +0,0 @@ -/* WaybackLogic - * - * Created on 2005/10/18 14:00:00 - * - * Copyright (C) 2005 Internet Archive. - * - * This file is part of the Wayback Machine (crawler.archive.org). - * - * Wayback Machine 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 Machine 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 Machine; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package org.archive.wayback.core; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Properties; -import java.util.logging.Logger; - -import org.archive.wayback.PropertyConfigurable; -import org.archive.wayback.ReplayRenderer; -import org.archive.wayback.QueryRenderer; -import org.archive.wayback.ResultURIConverter; -import org.archive.wayback.ResourceIndex; -import org.archive.wayback.ResourceStore; -import org.archive.wayback.exception.ConfigurationException; -import org.archive.wayback.query.OpenSearchQueryParser; - -/** - * Constructor and go-between for the major components in the Wayback Machine. - * - * @author Brad Tofel - * @version $Date$, $Revision$ - */ -public class WaybackLogic implements PropertyConfigurable { - private static final Logger LOGGER = Logger.getLogger(WaybackLogic.class - .getName()); - - private static final String REPLAY_URI_CONVERTER_PROPERTY = - "replayuriconverter"; - - private static final String REPLAY_RENDERER_PROPERTY = "replayrenderer"; - - private static final String QUERY_RENDERER_PROPERTY = "queryrenderer"; - - private static final String RESOURCE_STORE_PROPERTY = "resourcestore"; - - private static final String RESOURCE_INDEX_PROPERTY = "resourceindex"; - - private Properties configuration = null; - - Hashtable<String,PropertyConfigurable> objectCache = - new Hashtable<String, PropertyConfigurable>(); - - private static Hashtable<String, PropertyConfigurable> singletonCache = - new Hashtable<String, PropertyConfigurable>(); - - private OpenSearchQueryParser qp = null; - - /** - * Constructor - */ - public WaybackLogic() { - super(); - } - - /** - * Initialize this WaybackLogic. Pass in the specific configurations via - * Properties. Will ferret away the configuration properties, to be - * used later when constructing and initializing implementations of - * ResourceIndex, ResourceStore, QueryUI, ReplayUI, and - * ResultURIConverter. - * - * @param configuration - * Generic properties bag for configurations - */ - public void init(Properties configuration) { - - this.configuration = configuration; - } - - protected PropertyConfigurable getInstance(final Properties p, - final String classPrefix) throws ConfigurationException { - - LOGGER.info("WaybackLogic constructing " + classPrefix + "..."); - - PropertyConfigurable result = null; - - String classNameKey = classPrefix + ".classname"; - String propertyPrefix = classPrefix + "."; - String className = null; - - // build new class-specific Properties for class initialization: - Properties classProperties = new Properties(); - for (Enumeration e = p.keys(); e.hasMoreElements();) { - String key = (String) e.nextElement(); - - if (key.equals(classNameKey)) { - - // special .classname value: - className = p.getProperty(key); - - } else if (key.startsWith(propertyPrefix)) { - - String finalKey = key.substring(propertyPrefix.length()); - String value = p.getProperty(key); - classProperties.put(finalKey, value); - - } - } - - // did we find the implementation class? - if (className == null) { - throw new ConfigurationException("No configuration for (" - + classNameKey + ")"); - } - - try { - result = (PropertyConfigurable) Class.forName(className) - .newInstance(); - } catch (Exception e) { - e.printStackTrace(); - throw new ConfigurationException(e.getMessage()); - } - LOGGER.info("new " + className + " created."); - result.init(p); - LOGGER.info("initialized " + className); - - return result; - } - - /** - * possibly initializes and returns a singleton instance of class className - * - * @param className - * @return object of PropertyConfigurable class that has been configured - * with a call to init() - * @throws ConfigurationException - */ - public synchronized PropertyConfigurable getCachedSingleton(final String className) - throws ConfigurationException { - if(!singletonCache.containsKey(className)) { - singletonCache.put(className,getInstance(configuration,className)); - } - return singletonCache.get(className); - } - - /** - * possibly initializes and returns an instance of class className - * - * @param className - * @return object of PropertyConfigurable class that has been configured - * with a call to init() - * @throws ConfigurationException - */ - public synchronized PropertyConfigurable getCachedInstance(final String className) - throws ConfigurationException { - if(!objectCache.containsKey(className)) { - objectCache.put(className,getInstance(configuration,className)); - } - return objectCache.get(className); - } - - /** - * possibly initializes and returns the resourceIndex - * - * @return Returns the resourceIndex. - * @throws ConfigurationException - */ - public ResourceIndex getResourceIndex() throws ConfigurationException { - return (ResourceIndex) getCachedSingleton(RESOURCE_INDEX_PROPERTY); - - } - - /** - * possibly initializes and returns the resourceStore - * - * @return Returns the resourceStore. - * @throws ConfigurationException - */ - public ResourceStore getResourceStore() throws ConfigurationException { - return (ResourceStore) getCachedSingleton(RESOURCE_STORE_PROPERTY); - } - - /** - * possibly initializes and returns the uriConverter - * - * @return Returns the uriConverter. - * @throws ConfigurationException - */ - public ResultURIConverter getURIConverter() - throws ConfigurationException { - return (ResultURIConverter) getCachedInstance( - REPLAY_URI_CONVERTER_PROPERTY); - } - - /** - * possibly initializes and returns the replayRenderer - * - * @return Returns the replayRenderer. - * @throws ConfigurationException - */ - public ReplayRenderer getReplayRenderer() throws ConfigurationException { - return (ReplayRenderer) getCachedInstance(REPLAY_RENDERER_PROPERTY); - } - - /** - * possibly initializes and returns the queryRenderer - * - * @return Returns the queryRenderer. - * @throws ConfigurationException - */ - public QueryRenderer getQueryRenderer() throws ConfigurationException { - return (QueryRenderer) getCachedInstance(QUERY_RENDERER_PROPERTY); - } - /** - * possibly initializes and returns the resourceIndex - * - * @return Returns the resourceIndex. - * @throws ConfigurationException - */ - public synchronized OpenSearchQueryParser getQueryParser() - throws ConfigurationException { - if(qp == null) { - qp = new OpenSearchQueryParser(); - qp.init(configuration); - } - return qp; - } - -} Deleted: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackServlet.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackServlet.java 2007-07-20 01:24:30 UTC (rev 1850) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/WaybackServlet.java 2007-07-20 01:25:30 UTC (rev 1851) @@ -1,96 +0,0 @@ -/* WaybackServlet - * - * $Id$ - * - * Created on 4:42:13 PM May 9, 2006. - * - * Copyright (C) 2006 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.core; - -import java.text.ParseException; -import java.util.Enumeration; -import java.util.Map; -import java.util.Properties; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; - -/** - * Base clas for HttpServlets that have the "project standard" WaybackLogic - * factory for accessing other components. - * - * @author brad - * @version $Date$, $Revision$ - */ -public class WaybackServlet extends HttpServlet { - - private static final long serialVersionUID = 1L; - protected WaybackLogic wayback = new WaybackLogic(); - - /** - * generic constructor. - */ - public WaybackServlet() { - super(); - } - - public void init(ServletConfig c) throws ServletException { - - Properties p = new Properties(); - ServletContext sc = c.getServletContext(); - for (Enumeration e = sc.getInitParameterNames(); e.hasMoreElements();) { - String key = (String) e.nextElement(); - p.put(key, sc.getInitParameter(key)); - } - for (Enumeration e = c.getInitParameterNames(); e.hasMoreElements();) { - String key = (String) e.nextElement(); - p.put(key, c.getInitParameter(key)); - } - - wayback.init(p); - } - - protected static String getMapParam(Map queryMap, String field) { - String arr[] = (String[]) queryMap.get(field); - if (arr == null || arr.length == 0) { - return null; - } - return arr[0]; - } - - protected static String getRequiredMapParam(Map queryMap, String field) - throws ParseException { - String value = getMapParam(queryMap,field); - if(value == null) { - throw new ParseException("missing field " + field,0); - } - if(value.length() == 0) { - throw new ParseException("empty field " + field,0); - } - return value; - } - - protected static String getMapParamOrEmpty(Map map, String param) { - String val = getMapParam(map,param); - return (val == null) ? "" : val; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2008-07-01 23:13:24
|
Revision: 2349 http://archive-access.svn.sourceforge.net/archive-access/?rev=2349&view=rev Author: bradtofel Date: 2008-07-01 16:13:28 -0700 (Tue, 01 Jul 2008) Log Message: ----------- MAJOR REFACTOR: previously under-specified SearchResult is now explicitly broken into CaptureSearchResult and UrlSearchResult, with handy accessor methods, moving of Constant references into these classes, and many many more edits to achieve. Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResult.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResult.java Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResult.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResult.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResult.java 2008-07-01 23:13:28 UTC (rev 2349) @@ -0,0 +1,234 @@ +/* CaptureSearchResult + * + * $Id$ + * + * Created on 7:39:24 PM Jun 26, 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.core; + +import java.util.Date; + +import org.archive.wayback.util.url.UrlOperations; + +/** + * + * + * @author brad + * @version $Date$, $Revision$ + */ +public class CaptureSearchResult extends SearchResult { + + private long cachedOffset = -1; + private long cachedDate = -1; + + public static final String CAPTURE_ORIGINAL_URL = "originalurl"; + + /** + * Result: canonicalized(lookup key) form of URL of captured document + */ + public static final String CAPTURE_URL_KEY = "urlkey"; + + /** + * Result: 14-digit timestamp when document was captured + */ + public static final String CAPTURE_CAPTURE_TIMESTAMP = "capturetimestamp"; + + /** + * Result: basename of ARC file containing this document. + */ + public static final String CAPTURE_FILE = "file"; + + /** + * Result: compressed byte offset within ARC file where this document's + * gzip envelope begins. + */ + public static final String CAPTURE_OFFSET = "compressedoffset"; + + /** + * Result: compressed byte offset within ARC file where this document's + * gzip envelope Ends. + */ + public static final String CAPTURE_END_OFFSET = "compressedendoffset"; + + /** + * Result: best-guess at mime-type of this document. + */ + public static final String CAPTURE_MIME_TYPE = "mimetype"; + + /** + * Result: 3-digit integer HTTP response code. may be '0' in some + * fringe conditions, old ARCs, bug in crawler, etc. + */ + public static final String CAPTURE_HTTP_CODE = "httpresponsecode"; + + /** + * Result: some form of document fingerprint. This should represent the + * HTTP payload only for HTTP captured resources. It may represent an MD5, a + * SHA1, and may be a fragment of the full representation of the digest. + */ + public static final String CAPTURE_DIGEST= "digest"; + + /** + * Result: URL that this document redirected to, or '-' if it does + * not redirect + */ + public static final String CAPTURE_REDIRECT_URL = "redirecturl"; + + /** + * Result: flag within a SearchResult that indicates this is the closest to + * a particular requested date. + */ + public static final String CAPTURE_CLOSEST_INDICATOR = "closest"; + public static final String CAPTURE_CLOSEST_VALUE = "true"; + + /** + * Result: this key being present indicates that this particular capture + * was not actually stored, and that other values within this SearchResult + * are actually values from a different record which *should* be identical + * to this capture, had it been stored. + */ + public static final String CAPTURE_DUPLICATE_ANNOTATION = "duplicate"; + + /** + * Result: this key is present when the CAPTURE_DUPLICATE_ANNOTATION is also + * present, with the value indicating the last date that was actually + * stored for this duplicate. + */ + public static final String CAPTURE_DUPLICATE_STORED_TS = "duplicate-ts"; + + /** + * flag indicates that this document was downloaded and verified as + * identical to a previous capture by digest. + */ + public static final String CAPTURE_DUPLICATE_DIGEST = "digest"; + + /** + * flag indicates that this document was NOT downloaded, but that the + * origin server indicated that the document had not changed, based on + * If-Modified HTTP request headers. + */ + public static final String CAPTURE_DUPLICATE_HTTP = "http"; + public String getOriginalUrl() { + return get(CAPTURE_ORIGINAL_URL); + } + public void setOriginalUrl(String originalUrl) { + put(CAPTURE_ORIGINAL_URL,originalUrl); + } + public String getOriginalHost() { + return UrlOperations.urlToHost(getOriginalUrl()); + } + public String getUrlKey() { + return get(CAPTURE_URL_KEY); + } + public void setUrlKey(String urlKey) { + put(CAPTURE_URL_KEY,urlKey); + } + public Date getCaptureDate() { + if(cachedDate == -1) { + cachedDate = tsToDate(getCaptureTimestamp()).getTime(); + } + return new Date(cachedDate); + } + public void setCaptureDate(Date date) { + cachedDate = date.getTime(); + put(CAPTURE_CAPTURE_TIMESTAMP, dateToTS(date)); + } + public String getCaptureTimestamp() { + return get(CAPTURE_CAPTURE_TIMESTAMP); + } + public void setCaptureTimestamp(String timestamp) { + put(CAPTURE_CAPTURE_TIMESTAMP,timestamp); + } + public String getFile() { + return get(CAPTURE_FILE); + } + public void setFile(String file) { + put(CAPTURE_FILE, file); + } + public long getOffset() { + if(cachedOffset == -1) { + cachedOffset = Long.parseLong(get(CAPTURE_OFFSET)); + } + return cachedOffset; + } + public void setOffset(long offset) { + cachedOffset = offset; + put(CAPTURE_OFFSET,String.valueOf(offset)); + } + public String getMimeType() { + return get(CAPTURE_MIME_TYPE); + } + public void setMimeType(String mimeType) { + put(CAPTURE_MIME_TYPE,mimeType); + } + public String getHttpCode() { + return get(CAPTURE_HTTP_CODE); + } + public void setHttpCode(String httpCode) { + put(CAPTURE_HTTP_CODE,httpCode); + } + public String getDigest() { + return get(CAPTURE_DIGEST); + } + public void setDigest(String digest) { + put(CAPTURE_DIGEST,digest); + } + public String getRedirectUrl() { + return get(CAPTURE_REDIRECT_URL); + } + public void setRedirectUrl(String url) { + put(CAPTURE_REDIRECT_URL,url); + } + public boolean isClosest() { + return getBoolean(CAPTURE_CLOSEST_INDICATOR); + } + public void setClosest(boolean value) { + putBoolean(CAPTURE_CLOSEST_INDICATOR,value); + } + public void flagDuplicateDigest(Date storedDate) { + put(CAPTURE_DUPLICATE_ANNOTATION,CAPTURE_DUPLICATE_DIGEST); + put(CAPTURE_DUPLICATE_STORED_TS,dateToTS(storedDate)); + } + public void flagDuplicateDigest(String storedTS) { + put(CAPTURE_DUPLICATE_ANNOTATION,CAPTURE_DUPLICATE_DIGEST); + put(CAPTURE_DUPLICATE_STORED_TS,storedTS); + } + public boolean isDuplicateDigest() { + String dupeType = get(CAPTURE_DUPLICATE_ANNOTATION); + return (dupeType != null && dupeType.equals(CAPTURE_DUPLICATE_DIGEST)); + } + public Date getDuplicateDigestStoredDate() { + String dupeType = get(CAPTURE_DUPLICATE_ANNOTATION); + Date date = null; + if(dupeType != null && dupeType.equals(CAPTURE_DUPLICATE_DIGEST)) { + date = tsToDate(get(CAPTURE_DUPLICATE_STORED_TS)); + } + return date; + } + public String getDuplicateDigestStoredTimestamp() { + String dupeType = get(CAPTURE_DUPLICATE_ANNOTATION); + String ts = null; + if(dupeType != null && dupeType.equals(CAPTURE_DUPLICATE_DIGEST)) { + ts = get(CAPTURE_DUPLICATE_STORED_TS); + } + return ts; + } +} Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResult.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResult.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResult.java 2008-07-01 23:13:28 UTC (rev 2349) @@ -0,0 +1,117 @@ +/* UrlSearchResult + * + * $Id$ + * + * Created on 7:42:06 PM Jun 26, 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.core; + +import java.util.Date; + +/** + * + * + * @author brad + * @version $Date$, $Revision$ + */ +public class UrlSearchResult extends SearchResult { + private long cachedFirst = -1; + private long cachedLast = -1; + private long cachedNumVersions = -1; + private long cachedNumCaptures = -1; + + public final static String URL_KEY = "urlkey"; + public final static String URL_ORIGINAL_URL = "originalurl"; + public final static String URL_FIRST_CAPTURE_TIMESTAMP = "firstcapturets"; + public final static String URL_LAST_CAPTURE_TIMESTAMP = "lastcapturets"; + public final static String URL_NUM_CAPTURES = "numcaptures"; + public final static String URL_NUM_VERSIONS = "numversions"; + public String getUrlKey() { + return get(URL_KEY); + } + public void setUrlKey(String urlKey) { + put(URL_KEY,urlKey); + } + public String getOriginalUrl() { + return get(URL_ORIGINAL_URL); + } + public void setOriginalUrl(String originalUrl) { + put(URL_ORIGINAL_URL,originalUrl); + } + public String getFirstCaptureTimestamp() { + return get(URL_FIRST_CAPTURE_TIMESTAMP); + } + public Date getFirstCaptureDate() { + if(cachedFirst == -1) { + cachedFirst = tsToDate(getFirstCaptureTimestamp()).getTime(); + } + return new Date(cachedFirst); + } + public void setFirstCapture(Date date) { + cachedFirst = date.getTime(); + put(URL_FIRST_CAPTURE_TIMESTAMP, dateToTS(date)); + } + public void setFirstCapture(String timestamp) { + put(URL_FIRST_CAPTURE_TIMESTAMP, timestamp); + } + public String getLastCaptureTimestamp() { + return get(URL_LAST_CAPTURE_TIMESTAMP); + } + public Date getLastCaptureDate() { + if(cachedLast == -1) { + cachedLast = tsToDate(getLastCaptureTimestamp()).getTime(); + } + return new Date(cachedLast); + } + public void setLastCapture(Date date) { + cachedLast = date.getTime(); + put(URL_LAST_CAPTURE_TIMESTAMP, dateToTS(date)); + } + public void setLastCapture(String timestamp) { + put(URL_LAST_CAPTURE_TIMESTAMP, timestamp); + } + public long getNumCaptures() { + if(cachedNumCaptures == -1) { + cachedNumCaptures = Long.parseLong(get(URL_NUM_CAPTURES)); + } + return cachedNumCaptures; + } + public void setNumCaptures(long numCaptures) { + cachedNumCaptures = numCaptures; + put(URL_NUM_CAPTURES,String.valueOf(numCaptures)); + } + public void setNumCaptures(String numCaptures) { + put(URL_NUM_CAPTURES,numCaptures); + } + public long getNumVersions() { + if(cachedNumVersions == -1) { + cachedNumVersions = Long.parseLong(get(URL_NUM_VERSIONS)); + } + return cachedNumVersions; + } + public void setNumVersions(long numVersions) { + cachedNumVersions = numVersions; + put(URL_NUM_VERSIONS,String.valueOf(numVersions)); + } + public void setNumVersions(String numVersions) { + put(URL_NUM_VERSIONS,numVersions); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2008-07-01 23:16:14
|
Revision: 2350 http://archive-access.svn.sourceforge.net/archive-access/?rev=2350&view=rev Author: bradtofel Date: 2008-07-01 16:16:20 -0700 (Tue, 01 Jul 2008) Log Message: ----------- REFACTOR: these are now base classes with common method for (Url|Capture)SearchResult(s) classes. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResult.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResult.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResult.java 2008-07-01 23:13:28 UTC (rev 2349) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResult.java 2008-07-01 23:16:20 UTC (rev 2350) @@ -24,10 +24,10 @@ */ package org.archive.wayback.core; -import java.util.Properties; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; -import org.archive.wayback.WaybackConstants; - /** * * @@ -35,6 +35,9 @@ * @version $Date$, $Revision$ */ public class SearchResult { + + public static final String RESULT_TRUE_VALUE = "true"; + /** * Expandable Data bag for String to String tuples -- who knows what data * we'll want to put in an Index. Perhaps this should BE a Properties, @@ -42,71 +45,39 @@ * 'type' field that would allow discrimination/hinting at what kind * of data might be found in the Properties... */ - private Properties data = null; - - /** - * Constructor - */ + protected HashMap<String,String> data = null; + public SearchResult() { - super(); - data = new Properties(); + data = new HashMap<String,String>(); } - - /** - * @param key - * @return boolean true if 'key' is a key in 'data' - */ - public boolean containsKey(String key) { - return data.containsKey(key); - } - - /** - * @param key - * @return String value for key 'key' -- null if 'key' does not exist - */ public String get(String key) { - return (String) data.get(key); + return data.get(key); } - - /** - * @param key - * @param value - * @return String previous value of 'key' - */ - public String put(String key, String value) { - return (String) data.put(key, value); + public void put(String key, String value) { + data.put(key,value); } - - /** - * @return Returns the data. - */ - public Properties getData() { - return data; + public boolean getBoolean(String key) { + String value = get(key); + return (value != null && value.equals(RESULT_TRUE_VALUE)); } - - /** - * @return the (probably) 14-digit timestamp indicating when this capture - * was made. - */ - public String getCaptureDate() { - return get(WaybackConstants.RESULT_CAPTURE_DATE); + public void putBoolean(String key, boolean value) { + if(value) { + put(key,RESULT_TRUE_VALUE); + } else { + data.remove(key); + } } - - /** - * @return the url that created this request, without the leading http:// - */ - public String getUrl() { - return get(WaybackConstants.RESULT_URL); + protected String dateToTS(Date date) { + return new Timestamp(date).getDateStr(); } - - /** - * @return the url that created this request, including the leading http:// - */ - public String getAbsoluteUrl() { - String url = get(WaybackConstants.RESULT_URL); - if(url.startsWith(WaybackConstants.HTTP_URL_PREFIX)) { - return url; - } - return WaybackConstants.HTTP_URL_PREFIX + url; + protected Date tsToDate(String timestamp) { + return Timestamp.parseBefore(timestamp).getDate(); } + public Map<String, String> toCanonicalStringMap() { + return data; + } + public void fromCanonicalStringMap(Map<String, String> canonical) { + data = new HashMap<String, String>(); + data.putAll(canonical); + } } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java 2008-07-01 23:13:28 UTC (rev 2349) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/SearchResults.java 2008-07-01 23:16:20 UTC (rev 2350) @@ -24,9 +24,8 @@ */ package org.archive.wayback.core; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Properties; +import java.util.HashMap; +import java.util.Map; /** * @@ -36,100 +35,42 @@ */ public abstract class SearchResults { /** - * List of SearchResult objects for index records matching a query + * Results: int total number of records matching, not all necc. returned. */ - protected ArrayList<SearchResult> results = null; + public static final String RESULTS_NUM_RESULTS = "numresults"; + /** - * 14-digit timestamp of first capture date contained in the SearchResults + * Results: int first record of all matching returned, 1-based */ - protected String firstResultDate; + public static final String RESULTS_FIRST_RETURNED = "firstreturned"; + /** - * 14-digit timestamp of last capture date contained in the SearchResults + * Results: int total number of records *returned* in results */ - protected String lastResultDate; + public static final String RESULTS_NUM_RETURNED = "numreturned"; + /** + * Results: int number of results requested + */ + public static final String RESULTS_REQUESTED = "resultsrequested"; + /** * Expandable data bag for tuples associated with the search results, * likely examples might be "total matching documents", "index of first * document returned", etc. */ - private Properties filters = new Properties(); - + private HashMap<String,String> filters = null; /** * Constructor */ public SearchResults() { - super(); - results = new ArrayList<SearchResult>(); + filters = new HashMap<String,String>(); } - /** - * @return true if no SearchResult objects, false otherwise. - */ - public boolean isEmpty() { - return results.isEmpty(); - } + private long returnedCount = -1; + private long firstReturned = -1; + private long matchingCount = -1; + private long numRequested = -1; /** - * @param result - * @param append - */ - public void addSearchResultRaw(final SearchResult result, - final boolean append) { - - if(append) { - results.add(result); - } else { - results.add(0,result); - } - } - - /** - * @return one of "Url" or "Capture" depending on the type of results - * contained in this object - */ - public abstract String getResultsType(); - - /** - * append a result - * @param result - */ - public abstract void addSearchResult(final SearchResult result); - /** - * add a result to this results, at either the begginning or at the end, - * depending on the append argument - * @param result - * SearchResult to add to this set - * @param append - */ - public abstract void addSearchResult(final SearchResult result, - final boolean append); - - /** - * @return number of SearchResult objects contained in these SearchResults - */ - public int getResultCount() { - return results.size(); - } - - /** - * @return an Iterator that contains the SearchResult objects - */ - public Iterator<SearchResult> iterator() { - return results.iterator(); - } - /** - * @return Returns the firstResultDate. - */ - public String getFirstResultDate() { - return firstResultDate; - } - /** - * @return Returns the lastResultDate. - */ - public String getLastResultDate() { - return lastResultDate; - } - - /** * @param key * @return boolean, true if key 'key' exists in filters */ @@ -142,7 +83,7 @@ * @return value of key 'key' in filters */ public String getFilter(String key) { - return filters.getProperty(key); + return filters.get(key); } /** @@ -151,12 +92,66 @@ * @return previous String value of key 'key' or null if there was none */ public String putFilter(String key, String value) { - return (String) filters.setProperty(key, value); + return (String) filters.put(key, value); } /** * @return Returns the filters. */ - public Properties getFilters() { + public Map<String,String> getFilters() { return filters; } + private long getLongFilter(String key) { + String tmp = getFilter(key); + if(tmp == null) { + return 0; + } + return Long.parseLong(tmp); + } + + public long getReturnedCount() { + if(returnedCount == -1) { + returnedCount = getLongFilter(RESULTS_NUM_RETURNED); + } + return returnedCount; + } + public void setReturnedCount(long returnedCount) { + this.returnedCount = returnedCount; + putFilter(RESULTS_NUM_RETURNED, String.valueOf(returnedCount)); + } + + public long getFirstReturned() { + if(firstReturned == -1) { + firstReturned = getLongFilter(RESULTS_FIRST_RETURNED); + } + return firstReturned; + } + + public void setFirstReturned(long firstReturned) { + this.firstReturned = firstReturned; + putFilter(RESULTS_FIRST_RETURNED, String.valueOf(firstReturned)); + } + + public long getMatchingCount() { + if(matchingCount == -1) { + matchingCount = getLongFilter(RESULTS_NUM_RESULTS); + } + return matchingCount; + } + + public void setMatchingCount(long matchingCount) { + this.matchingCount = matchingCount; + putFilter(RESULTS_NUM_RESULTS, String.valueOf(matchingCount)); + } + + public long getNumRequested() { + if(numRequested == -1) { + numRequested = getLongFilter(RESULTS_REQUESTED); + } + return numRequested; + } + + public void setNumRequested(long numRequested) { + this.numRequested = numRequested; + putFilter(RESULTS_REQUESTED, String.valueOf(numRequested)); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bra...@us...> - 2008-07-01 23:16:37
|
Revision: 2351 http://archive-access.svn.sourceforge.net/archive-access/?rev=2351&view=rev Author: bradtofel Date: 2008-07-01 16:16:44 -0700 (Tue, 01 Jul 2008) Log Message: ----------- REFACTOR: now these classes are directly aware of the type of SearchResult they contain. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java 2008-07-01 23:16:20 UTC (rev 2350) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/CaptureSearchResults.java 2008-07-01 23:16:44 UTC (rev 2351) @@ -24,7 +24,8 @@ */ package org.archive.wayback.core; -import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; import java.util.Iterator; import org.archive.wayback.WaybackConstants; @@ -36,62 +37,113 @@ * @version $Date$, $Revision$ */ public class CaptureSearchResults extends SearchResults { - public String getResultsType() { - return WaybackConstants.RESULTS_TYPE_CAPTURE; + /** + * List of UrlSearchResult objects for index records matching a query + */ + private ArrayList<CaptureSearchResult> results = + new ArrayList<CaptureSearchResult>(); + /** + * 14-digit timestamp of first capture date contained in the SearchResults + */ + private String firstResultTimestamp; + + /** + * 14-digit timestamp of last capture date contained in the SearchResults + */ + private String lastResultTimestamp; + + /** + * @return Returns the 14-digit String Timestamp of the first Capture in + * this set of SearchResult objects + */ + public String getFirstResultTimestamp() { + return firstResultTimestamp; } /** - * append a result - * @param result + * @return Returns the firstResult Date. */ - public void addSearchResult(final SearchResult result) { - addSearchResult(result,true); + public Date getFirstResultDate() { + return new Timestamp(firstResultTimestamp).getDate(); } + /** - * add a result to this results, at either the begginning or at the end, - * depending on the append argument - * @param result - * SearchResult to add to this set - * @param append + * @return Returns the 14-digit String Timestamp of the last Capture in + * this set of SearchResult objects */ - public void addSearchResult(final SearchResult result, final boolean append) { - String resultDate = result.get(WaybackConstants.RESULT_CAPTURE_DATE); - if((firstResultDate == null) || - (firstResultDate.compareTo(resultDate) > 0)) { - firstResultDate = resultDate; - } - if((lastResultDate == null) || - (lastResultDate.compareTo(resultDate) < 0)) { - lastResultDate = resultDate; - } - addSearchResultRaw(result,append); + public String getLastResultTimestamp() { + return lastResultTimestamp; } + + public Date getLastResultDate() { + return new Timestamp(lastResultTimestamp).getDate(); + } + /** * @param wbRequest - * @return The closest SearchResult to the request. - * @throws ParseException + * @return The closest CaptureSearchResult to the request. */ - public SearchResult getClosest(WaybackRequest wbRequest) { + public CaptureSearchResult getClosest(WaybackRequest wbRequest) { - SearchResult closest = null; + CaptureSearchResult closest = null; long closestDistance = 0; - SearchResult cur = null; - Timestamp wantTimestamp; - wantTimestamp = Timestamp.parseBefore(wbRequest - .get(WaybackConstants.REQUEST_EXACT_DATE)); + CaptureSearchResult cur = null; + long wantTime = Timestamp.parseBefore(wbRequest + .get(WaybackConstants.REQUEST_EXACT_DATE)).getDate().getTime(); - Iterator<SearchResult> itr = results.iterator(); + Iterator<CaptureSearchResult> itr = results.iterator(); while (itr.hasNext()) { cur = itr.next(); - long curDistance; - Timestamp curTimestamp = Timestamp.parseBefore(cur - .get(WaybackConstants.RESULT_CAPTURE_DATE)); - curDistance = curTimestamp.absDistanceFromTimestamp(wantTimestamp); - + long curDistance = Math.abs(wantTime - + cur.getCaptureDate().getTime()); + if ((closest == null) || (curDistance < closestDistance)) { closest = cur; closestDistance = curDistance; } } return closest; + } + /** + * append a result + * @param result + */ + public void addSearchResult(CaptureSearchResult result) { + addSearchResult(result,true); + } + /** + * add a result to this results, at either the begginning or at the end, + * depending on the append argument + * @param result + * SearchResult to add to this set + * @param append + */ + public void addSearchResult(CaptureSearchResult result, boolean append) { + String resultDate = result.getCaptureTimestamp(); + if((firstResultTimestamp == null) || + (firstResultTimestamp.compareTo(resultDate) > 0)) { + firstResultTimestamp = resultDate; + } + if((lastResultTimestamp == null) || + (lastResultTimestamp.compareTo(resultDate) < 0)) { + lastResultTimestamp = resultDate; + } + + if(append) { + results.add(result); + } else { + results.add(0,result); + } } + + public boolean isEmpty() { + return results.isEmpty(); + } + + public Iterator<CaptureSearchResult> iterator() { + return results.iterator(); + } + + public int size() { + return results.size(); + } } Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java 2008-07-01 23:16:20 UTC (rev 2350) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/core/UrlSearchResults.java 2008-07-01 23:16:44 UTC (rev 2351) @@ -24,7 +24,8 @@ */ package org.archive.wayback.core; -import org.archive.wayback.WaybackConstants; +import java.util.ArrayList; +import java.util.Iterator; /** * @@ -33,19 +34,33 @@ * @version $Date$, $Revision$ */ public class UrlSearchResults extends SearchResults { + /** + * List of UrlSearchResult objects for index records matching a query + */ + private ArrayList<UrlSearchResult> results = + new ArrayList<UrlSearchResult>(); - public String getResultsType() { - return WaybackConstants.RESULTS_TYPE_URL; - } - public void addSearchResult(SearchResult result) { + public void addSearchResult(UrlSearchResult result) { addSearchResult(result,true); } - /* (non-Javadoc) - * @see org.archive.wayback.core.SearchResults#addSearchResult(org.archive.wayback.core.SearchResult, boolean) - */ - @Override - public void addSearchResult(SearchResult result, boolean append) { - addSearchResultRaw(result,append); + public void addSearchResult(UrlSearchResult result, boolean append) { + if(append) { + results.add(result); + } else { + results.add(0,result); + } } + + public boolean isEmpty() { + return results.isEmpty(); + } + + public Iterator<UrlSearchResult> iterator() { + return results.iterator(); + } + + public int size() { + return results.size(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |