Update of /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv901/src/java/org/archive/wayback/core Modified Files: ResourceResults.java WaybackLogic.java Timestamp.java WMRequest.java Resource.java ResourceResult.java Log Message: lots of javadoc comments Index: ResourceResult.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/ResourceResult.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ResourceResult.java 18 Oct 2005 02:30:48 -0000 1.1 --- ResourceResult.java 19 Oct 2005 01:22:36 -0000 1.2 *************** *** 1,2 **** --- 1,25 ---- + /* ResourceResult + * + * 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; *************** *** 5,8 **** --- 28,38 ---- import org.archive.io.arc.ARCLocation; + /** + * Encapsulates the data for a single Resource (in an ARC file) returned from a + * ResourceIndex query. + * + * @author Brad Tofel + * @version $Date$, $Revision$ + */ public class ResourceResult { private final static String CDX_HEADER_STRING = " CDX N b h m s k r V g"; *************** *** 26,33 **** --- 56,71 ---- private String arcFileName = null; + /** + * Constructor + */ public ResourceResult() { super(); } + /** + * get the ARCLocation object corresponding to this ResourceResult. + * + * @return ARCLocation object. + */ public ARCLocation getARCLocation() { final String daArcName = arcFileName; *************** *** 48,51 **** --- 86,98 ---- } + /** + * Attempt to deserialize state from a single text line, fields delimited by + * spaces. There are standard ways to do this, and this is not one of + * them... for no good reason. + * + * @param line + * @param lineNumber + * @throws ParseException + */ public void parseLine(final String line, final int lineNumber) throws ParseException { *************** *** 65,68 **** --- 112,121 ---- } + /** + * get the CDX header line for the format serialized and deserialized in + * flat file format. + * + * @return String representation of the CDX header line, WITHOUT NEWLINE. + */ public static String getCDXHeaderString() { return CDX_HEADER_STRING; *************** *** 75,119 **** } ! public String toShortString() { ! return url + "\t" + timestamp.getDateStr() + "\t" + compressedOffset ! + "\t" + arcFileName; ! } ! public String getArcFileName() { return arcFileName; } public long getCompressedOffset() { return compressedOffset; } public String getHttpResponseCode() { return httpResponseCode; } public String getMd5Fragment() { return md5Fragment; } public String getMimeType() { return mimeType; } public String getOrigHost() { return origHost; } public String getRedirectUrl() { return redirectUrl; } public boolean isRedirect() { return (0 != redirectUrl.compareTo("-")); } public Timestamp getTimestamp() { return timestamp; } public String getUrl() { return url; --- 128,209 ---- } ! /** ! * @return arcFileName property ! */ public String getArcFileName() { return arcFileName; } + /** + * @return compressedOffset property + */ public long getCompressedOffset() { return compressedOffset; } + /** + * @return String representation of the HTTP response code property. + */ public String getHttpResponseCode() { return httpResponseCode; } + /** + * @return MD5 digest property in hex-dec format, possible truncated to less + * than 32 characters. + */ public String getMd5Fragment() { return md5Fragment; } + /** + * @return mimeType property + */ public String getMimeType() { return mimeType; } + /** + * @return the original fully qualified String hostname from which this + * resource was acquired. + */ public String getOrigHost() { return origHost; } + /** + * @return the String URL to which this resource redirects, or "-" if it + * does not redirect. + */ public String getRedirectUrl() { return redirectUrl; } + /** + * @return true if this resource is though to redirect to another URL, false + * otherwise. + */ public boolean isRedirect() { return (0 != redirectUrl.compareTo("-")); } + /** + * @return Returns the timestamp. + */ public Timestamp getTimestamp() { return timestamp; } + /** + * @param timestamp + * The timestamp to set. + */ + public void setTimestamp(Timestamp timestamp) { + this.timestamp = timestamp; + } + + /** + * @return Returns the url. + */ public String getUrl() { return url; *************** *** 121,165 **** /** ! * @param args */ ! public static void main(String[] args) { ! // TODO Auto-generated method stub ! } public void setArcFileName(String arcFileName) { this.arcFileName = arcFileName; } public void setCompressedOffset(long compressedOffset) { this.compressedOffset = compressedOffset; } public void setHttpResponseCode(String httpResponseCode) { this.httpResponseCode = httpResponseCode; } public void setMd5Fragment(String md5Fragment) { this.md5Fragment = md5Fragment; } public void setMimeType(String mimeType) { this.mimeType = mimeType; } public void setOrigHost(String origHost) { this.origHost = origHost; } public void setRedirectUrl(String redirectUrl) { this.redirectUrl = redirectUrl; } ! public void setTimeStamp(Timestamp timeStamp) { ! this.timestamp = timeStamp; ! } - public void setUrl(String url) { - this.url = url; } --- 211,282 ---- /** ! * @param url ! * The url to set. */ ! public void setUrl(String url) { ! this.url = url; } + /** + * @param arcFileName + * The arcFileName to set. + */ public void setArcFileName(String arcFileName) { this.arcFileName = arcFileName; } + /** + * @param compressedOffset + * The compressedOffset to set. + */ public void setCompressedOffset(long compressedOffset) { this.compressedOffset = compressedOffset; } + /** + * @param httpResponseCode + * The httpResponseCode to set. + */ public void setHttpResponseCode(String httpResponseCode) { this.httpResponseCode = httpResponseCode; } + /** + * @param md5Fragment + * The md5Fragment to set. + */ public void setMd5Fragment(String md5Fragment) { this.md5Fragment = md5Fragment; } + /** + * @param mimeType + * The mimeType to set. + */ public void setMimeType(String mimeType) { this.mimeType = mimeType; } + /** + * @param origHost + * The origHost to set. + */ public void setOrigHost(String origHost) { this.origHost = origHost; } + /** + * @param redirectUrl + * The redirectUrl to set. + */ public void setRedirectUrl(String redirectUrl) { this.redirectUrl = redirectUrl; } ! /** ! * @param args ! */ ! public static void main(String[] args) { } Index: WMRequest.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/WMRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WMRequest.java 18 Oct 2005 02:30:48 -0000 1.1 --- WMRequest.java 19 Oct 2005 01:22:36 -0000 1.2 *************** *** 1,2 **** --- 1,25 ---- + /* WMRequest + * + * 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; *************** *** 6,9 **** --- 29,39 ---- import org.archive.net.UURI; + /** + * Abstraction of all the data associated with a users request to the Wayback + * Machine. + * + * @author Brad Tofel + * @version $Date$, $Revision$ + */ public class WMRequest { private final Pattern IMAGE_REGEX = Pattern *************** *** 30,127 **** private boolean pathQuery = false; ! public UURI getRedirectURI() { ! return redirectURI; } ! public void setRedirectURI(UURI redirectURI) { ! this.redirectURI = redirectURI; } ! public WMRequest() { ! super(); ! // TODO Auto-generated constructor stub } ! public boolean isRetrieval() { ! return this.retrieval; } ! public boolean isQuery() { ! return this.query; } ! public boolean isPathQuery() { ! return this.pathQuery; } public Timestamp getExactTimestamp() { return exactTimestamp; } public void setExactTimestamp(Timestamp exactTimestamp) { this.exactTimestamp = exactTimestamp; } ! public Timestamp getEndTimestamp() { ! return endTimestamp; } ! public void setEndTimestamp(Timestamp endTimestamp) { ! this.endTimestamp = endTimestamp; } public String getReferrerUrl() { return referrerUrl; } public void setReferrerUrl(String referrerUrl) { this.referrerUrl = referrerUrl; } public UURI getRequestURI() { return requestURI; } public void setRequestURI(UURI requestURI) { this.requestURI = requestURI; } public Timestamp getStartTimestamp() { return startTimestamp; } public void setStartTimestamp(Timestamp startTimestamp) { this.startTimestamp = startTimestamp; } ! private void resetType() { ! this.retrieval = false; ! this.query = false; ! this.pathQuery = false; ! } ! ! public void setPathQuery() { ! resetType(); ! this.pathQuery = true; ! } ! ! public void setQuery() { ! resetType(); ! this.query = true; } ! public void setRetrieval() { ! resetType(); ! this.retrieval = true; } ! public boolean isImageRetrieval() { ! String uri = requestURI.getEscapedURI(); ! Matcher matcher = null; ! matcher = IMAGE_REGEX.matcher(uri); ! if (matcher != null && matcher.matches()) { ! return true; ! } ! return false; } --- 60,238 ---- private boolean pathQuery = false; ! /** ! * Constructor ! */ ! public WMRequest() { ! super(); } ! private void resetType() { ! this.retrieval = false; ! this.query = false; ! this.pathQuery = false; } ! /** ! * sets the request type to PathQuery ! */ ! public void setPathQuery() { ! resetType(); ! this.pathQuery = true; } ! /** ! * sets the request type to Query ! */ ! public void setQuery() { ! resetType(); ! this.query = true; } ! /** ! * sets the request type to Retrieval/Replay ! */ ! public void setRetrieval() { ! resetType(); ! this.retrieval = true; } ! /** ! * @return whether this request appears to be for an image, using only the ! * requested URL ! */ ! public boolean isImageRetrieval() { ! String uri = requestURI.getEscapedURI(); ! Matcher matcher = null; ! matcher = IMAGE_REGEX.matcher(uri); ! if (matcher != null && matcher.matches()) { ! return true; ! } ! return false; ! } ! ! /** ! * @return Returns the endTimestamp. ! */ ! public Timestamp getEndTimestamp() { ! return endTimestamp; ! } ! ! /** ! * @param endTimestamp ! * The endTimestamp to set. ! */ ! public void setEndTimestamp(Timestamp endTimestamp) { ! this.endTimestamp = endTimestamp; ! } ! ! /** ! * @return Returns the exactDateRequest. ! */ ! public String getExactDateRequest() { ! return exactDateRequest; } + /** + * @param exactDateRequest + * The exactDateRequest to set. + */ + public void setExactDateRequest(String exactDateRequest) { + this.exactDateRequest = exactDateRequest; + } + + /** + * @return Returns the exactTimestamp. + */ public Timestamp getExactTimestamp() { return exactTimestamp; } + /** + * @param exactTimestamp + * The exactTimestamp to set. + */ public void setExactTimestamp(Timestamp exactTimestamp) { this.exactTimestamp = exactTimestamp; } ! /** ! * @return Returns the redirectURI. ! */ ! public UURI getRedirectURI() { ! return redirectURI; } ! /** ! * @param redirectURI ! * The redirectURI to set. ! */ ! public void setRedirectURI(UURI redirectURI) { ! this.redirectURI = redirectURI; } + /** + * @return Returns the referrerUrl. + */ public String getReferrerUrl() { return referrerUrl; } + /** + * @param referrerUrl + * The referrerUrl to set. + */ public void setReferrerUrl(String referrerUrl) { this.referrerUrl = referrerUrl; } + /** + * @return Returns the requestURI. + */ public UURI getRequestURI() { return requestURI; } + /** + * @param requestURI + * The requestURI to set. + */ public void setRequestURI(UURI requestURI) { this.requestURI = requestURI; } + /** + * @return Returns the startTimestamp. + */ public Timestamp getStartTimestamp() { return startTimestamp; } + /** + * @param startTimestamp + * The startTimestamp to set. + */ public void setStartTimestamp(Timestamp startTimestamp) { this.startTimestamp = startTimestamp; } ! /** ! * @return Returns the pathQuery. ! */ ! public boolean isPathQuery() { ! return pathQuery; } ! /** ! * @return Returns the query. ! */ ! public boolean isQuery() { ! return query; } ! /** ! * @return Returns the retrieval. ! */ ! public boolean isRetrieval() { ! return retrieval; } *************** *** 130,143 **** */ public static void main(String[] args) { - // TODO Auto-generated method stub - - } - public String getExactDateRequest() { - return exactDateRequest; - } - - public void setExactDateRequest(String exactDateRequest) { - this.exactDateRequest = exactDateRequest; } --- 241,245 ---- Index: Resource.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/Resource.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Resource.java 18 Oct 2005 02:30:48 -0000 1.1 --- Resource.java 19 Oct 2005 01:22:36 -0000 1.2 *************** *** 1,19 **** ! /** ! * */ - package org.archive.wayback.core; ! import java.io.IOException; import org.archive.io.arc.ARCRecord; /** ! * @author brad ! * */ public class Resource { ! ARCRecord arcRecord = null; // probably this should inherit from ARCRecord... public Resource(final ARCRecord rec) { super(); --- 1,48 ---- ! /* Resource ! * ! * 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 org.archive.io.arc.ARCRecord; /** ! * Slightly more than an ARCRecord. This class is designed to be an abstraction ! * to allow the Wayback to operator with non-ARC file format resources. Probably ! * the interface required will end up looking very much like ARCRecord, but can ! * be reimplemented to handle new ARC formats or non-ARC formats. At the moment, ! * users of this class just grab the ARCRecord out and use it directly. ! * ! * @author Brad Tofel ! * @version $Date$, $Revision$ */ public class Resource { ! ARCRecord arcRecord = null; + /** + * Constructor + * + * @param rec + */ public Resource(final ARCRecord rec) { super(); *************** *** 21,40 **** } ! public String dumpRaw() throws IOException { ! arcRecord.skipHttpHeader(); ! String content = ""; ! ! byte[] outputBuffer = new byte[8 * 1024]; ! int read = outputBuffer.length; ! while ((read = arcRecord.read(outputBuffer, 0, outputBuffer.length)) != -1) { ! String tmpString = new String(outputBuffer, 0, read); ! content = content.concat(tmpString); ! //System.out.write(outputBuffer, 0, read); ! } ! //System.out.flush(); ! ! return content; ! } ! public ARCRecord getArcRecord() { return arcRecord; --- 50,56 ---- } ! /** ! * @return the ARCRecord underlying this Resource. ! */ public ARCRecord getArcRecord() { return arcRecord; *************** *** 45,49 **** */ public static void main(String[] args) { - // TODO Auto-generated method stub } --- 61,64 ---- Index: Timestamp.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/Timestamp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Timestamp.java 18 Oct 2005 02:30:48 -0000 1.1 --- Timestamp.java 19 Oct 2005 01:22:36 -0000 1.2 *************** *** 1,2 **** --- 1,25 ---- + /* Timestamp + * + * 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; *************** *** 6,9 **** --- 29,38 ---- import org.archive.util.ArchiveUtils; + /** + * Represents a moment in time as a 14-digit string, and interally as a Date. + * + * @author Brad Tofel + * @version $Date$, $Revision$ + */ public class Timestamp { private final static String FIRST1_TIMESTAMP = "19960101000000"; *************** *** 13,17 **** private final static String LAST1_TIMESTAMP = "19991231235959"; ! // private final static String LAST2_TIMESTAMP = "20311231235959"; private final static String LAST2_TIMESTAMP = "29991231235959"; --- 42,46 ---- private final static String LAST1_TIMESTAMP = "19991231235959"; ! // private final static String LAST2_TIMESTAMP = "20311231235959"; private final static String LAST2_TIMESTAMP = "29991231235959"; *************** *** 23,31 **** private Date date = null; public Timestamp() { super(); - // TODO Auto-generated constructor stub } public static Timestamp parseBefore(final String dateStr) throws ParseException { --- 52,68 ---- private Date date = null; + /** + * Constructor + */ public Timestamp() { super(); } + /** + * @param dateStr + * @return Timestamp object representing the earliest date represented by + * the (possibly) partial digit-string argument. + * @throws ParseException + */ public static Timestamp parseBefore(final String dateStr) throws ParseException { *************** *** 35,38 **** --- 72,81 ---- } + /** + * @param dateStr + * @return Timestamp object representing the latest date represented by the + * (possibly) partial digit-string argument. + * @throws ParseException + */ public static Timestamp parseAfter(final String dateStr) throws ParseException { *************** *** 42,45 **** --- 85,92 ---- } + /** + * @return Timestamp object representing the earliest possible date. + * @throws ParseException + */ public static Timestamp earliestTimestamp() throws ParseException { Timestamp ts = new Timestamp(); *************** *** 48,51 **** --- 95,102 ---- } + /** + * @return Timestamp object representing the latest possible date. + * @throws ParseException + */ public static Timestamp latestTimestamp() throws ParseException { Timestamp ts = new Timestamp(); *************** *** 54,57 **** --- 105,113 ---- } + /** + * @param sse + * @return Timestamp object representing the seconds since epoch argument. + * @throws ParseException + */ public static Timestamp fromSse(final int sse) throws ParseException { String dateStr = ArchiveUtils.get14DigitDate(sse * 1000); *************** *** 94,101 **** --- 150,167 ---- } + /** + * @return the 14-digit String representation of this Timestamp. + */ public String getDateStr() { return dateStr; } + /** + * initialize interal data structures for this Timestamp from the 14-digit + * argument. + * + * @param dateStr + * @throws ParseException + */ public void setDateStr(String dateStr) throws ParseException { date = ArchiveUtils.parse14DigitDate(dateStr); *************** *** 103,106 **** --- 169,176 ---- } + /** + * @return the integer number of seconds since epoch represented by this + * Timestamp. + */ public int sse() { return Math.round(date.getTime() / 1000); *************** *** 108,120 **** /** ! * function that calculates integer milliseconds between this records ! * timeStamp and the arguments timeStamp. result is the absolute ! * number of milliseconds difference. * ! * @param String 14 digit UTC representation of another timestamp. ! * @return int seconds between the argument and this records timestamp. ! * @throws ParseException if the inputstring was malformed */ - public long absDistanceFromTimestamp(final Timestamp otherTimeStamp) throws ParseException { --- 178,190 ---- /** ! * function that calculates integer milliseconds between this records ! * timeStamp and the arguments timeStamp. result is the absolute number of ! * milliseconds difference. * ! * @param otherTimeStamp ! * @return int absolute milliseconds between the argument and this records ! * timestamp. ! * @throws ParseException */ public long absDistanceFromTimestamp(final Timestamp otherTimeStamp) throws ParseException { *************** *** 123,136 **** /** ! * function that calculates integer milliseconds between this records ! * timeStamp and the arguments timeStamp. result is negative if ! * this records timeStamp is less than the argument, positive ! * if it is greater, and 0 if the same. ! * ! * @param String 14 digit UTC representation of another timestamp. ! * @return int seconds between the argument and this records timestamp. ! * @throws ParseException if the inputstring was malformed */ - public long distanceFromTimestamp(final Timestamp otherTimeStamp) throws ParseException { --- 193,205 ---- /** ! * function that calculates integer milliseconds between this records ! * timeStamp and the arguments timeStamp. result is negative if this records ! * timeStamp is less than the argument, positive if it is greater, and 0 if ! * the same. ! * ! * @param otherTimeStamp ! * @return long milliseconds ! * @throws ParseException */ public long distanceFromTimestamp(final Timestamp otherTimeStamp) throws ParseException { *************** *** 141,156 **** --- 210,238 ---- } + /** + * @return the year portion(first 4 digits) of this Timestamp + */ public String getYear() { return this.dateStr.substring(0, 4); } + /** + * @return the month portion(digits 5-6) of this Timestamp + */ public String getMonth() { return this.dateStr.substring(4, 6); } + /** + * @return the day portion(digits 7-8) of this Timestamp + */ public String getDay() { return this.dateStr.substring(6, 8); } + /** + * @return user friendly String representation of the Date of this + * Timestamp. + */ public String prettyDate() { String year = dateStr.substring(0, 4); *************** *** 165,168 **** --- 247,254 ---- } + /** + * @return user friendly String representation of the Time of this + * Timestamp. + */ public String prettyTime() { return dateStr.substring(8, 10) + ":" + dateStr.substring(10, 12) + ":" *************** *** 170,185 **** --- 256,296 ---- } + /** + * @return user friendly String representation of the Date and Time of this + * Timestamp. + */ public String prettyDateTime() { return prettyDate() + " " + prettyTime(); } + /** + * Presently unused, but possibly helpful in complex QueryUI generation. + * + * @return Timestamp representing the start of the Year this Timestamp + * occured in. + * @throws ParseException + */ public Timestamp startOfYear() throws ParseException { return parseBefore(dateStr.substring(0, 4)); } + /** + * Presently unused, but possibly helpful in complex QueryUI generation. + * + * @return Timestamp representing the start of the Month this Timestamp + * occured in. + * @throws ParseException + */ public Timestamp startOfMonth() throws ParseException { return parseBefore(dateStr.substring(0, 6)); } + /** + * Presently unused, but possibly helpful in complex QueryUI generation. + * + * @return Timestamp representing the start of the Week this Timestamp + * occured in. + * @throws ParseException + */ public Timestamp startOfWeek() throws ParseException { String yearMonth = dateStr.substring(0, 6); *************** *** 192,199 **** --- 303,324 ---- } + /** + * Presently unused, but possibly helpful in complex QueryUI generation. + * + * @return Timestamp representing the start of the Day this Timestamp + * occured in. + * @throws ParseException + */ public Timestamp startOfDay() throws ParseException { return parseBefore(dateStr.substring(0, 8)); } + /** + * Presently unused, but possibly helpful in complex QueryUI generation. + * + * @return Timestamp representing the start of the Hour this Timestamp + * occured in. + * @throws ParseException + */ public Timestamp startOfHour() throws ParseException { return parseBefore(dateStr.substring(0, 10)); *************** *** 204,228 **** */ public static void main(String[] args) { - // TODO Auto-generated method stub } } ! //public Date getDate() { ! //String[] ids = TimeZone.getAvailableIDs(0); ! //if(ids.length < 1) { ! // return null; ! //} ! //TimeZone gmt = new SimpleTimeZone(0,ids[0]); ! //Calendar cal = new GregorianCalendar(gmt); ! //int year = Integer.parseInt(dateStr.substring(0,4)); ! //int month = Integer.parseInt(dateStr.substring(4,2)) - 1; ! //int day = Integer.parseInt(dateStr.substring(6,2)); ! //int hour = Integer.parseInt(dateStr.substring(8,2)); ! //int min = Integer.parseInt(dateStr.substring(10,2)); ! //int sec = Integer.parseInt(dateStr.substring(12,2)); // ! //cal.set(year,month,day,hour,min,sec); ! //return cal.getTime(); ! //} // \ No newline at end of file --- 329,352 ---- */ public static void main(String[] args) { } } ! // public Date getDate() { ! // String[] ids = TimeZone.getAvailableIDs(0); ! // if(ids.length < 1) { ! // return null; ! // } ! // TimeZone gmt = new SimpleTimeZone(0,ids[0]); ! // Calendar cal = new GregorianCalendar(gmt); ! // int year = Integer.parseInt(dateStr.substring(0,4)); ! // int month = Integer.parseInt(dateStr.substring(4,2)) - 1; ! // int day = Integer.parseInt(dateStr.substring(6,2)); ! // int hour = Integer.parseInt(dateStr.substring(8,2)); ! // int min = Integer.parseInt(dateStr.substring(10,2)); ! // int sec = Integer.parseInt(dateStr.substring(12,2)); // ! // cal.set(year,month,day,hour,min,sec); ! // return cal.getTime(); ! // } // \ No newline at end of file Index: WaybackLogic.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/WaybackLogic.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WaybackLogic.java 18 Oct 2005 02:30:48 -0000 1.1 --- WaybackLogic.java 19 Oct 2005 01:22:36 -0000 1.2 *************** *** 1,2 **** --- 1,25 ---- + /* 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; *************** *** 9,12 **** --- 32,41 ---- import org.archive.wayback.ResourceStore; + /** + * Constructor and go-between for the major components in the Wayback Machine. + * + * @author Brad Tofel + * @version $Date$, $Revision$ + */ public class WaybackLogic { private static final Logger LOGGER = Logger.getLogger(WaybackLogic.class *************** *** 29,37 **** private ResourceStore resourceStore = null; public WaybackLogic() { super(); - // TODO Auto-generated constructor stub } public void init(Properties p) throws Exception { LOGGER.info("WaybackLogic constructing classes..."); --- 58,77 ---- private ResourceStore resourceStore = null; + /** + * Constructor + */ public WaybackLogic() { super(); } + /** + * Initialize this WaybackLogic. Pass in the specific configurations via + * Properties. Will construct and initialize implementations of + * ResourceIndex, ResourceResults, QueryUI, and ReplayUI. + * + * @param p + * Generic properties bag for configurations + * @throws Exception + */ public void init(Properties p) throws Exception { LOGGER.info("WaybackLogic constructing classes..."); *************** *** 84,108 **** /** ! * @param args */ - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - public QueryUI getQueryUI() { return queryUI; } public ReplayUI getReplayUI() { return replayUI; } public ResourceIndex getResourceIndex() { return resourceIndex; } public ResourceStore getResourceStore() { return resourceStore; } } --- 124,159 ---- /** ! * @return Returns the queryUI. */ public QueryUI getQueryUI() { return queryUI; } + /** + * @return Returns the replayUI. + */ public ReplayUI getReplayUI() { return replayUI; } + /** + * @return Returns the resourceIndex. + */ public ResourceIndex getResourceIndex() { return resourceIndex; } + /** + * @return Returns the resourceStore. + */ public ResourceStore getResourceStore() { return resourceStore; } + + /** + * @param args + */ + public static void main(String[] args) { + + } } Index: ResourceResults.java =================================================================== RCS file: /cvsroot/archive-access/archive-access/projects/wayback/src/java/org/archive/wayback/core/ResourceResults.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ResourceResults.java 18 Oct 2005 02:30:48 -0000 1.1 --- ResourceResults.java 19 Oct 2005 01:22:36 -0000 1.2 *************** *** 1,2 **** --- 1,25 ---- + /* ResourceResults + * + * 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; *************** *** 8,14 **** --- 31,46 ---- import org.archive.wayback.core.WMRequest; + /** + * Slightly more than an ArrayList of ResourceResult objects.. + * + * @author Brad Tofel + * @version $Date$, $Revision$ + */ public class ResourceResults { ArrayList results = null; + /** + * Constructor + */ public ResourceResults() { super(); *************** *** 16,31 **** --- 48,78 ---- } + /** + * @return true if no ResourceResult objects, false otherwise. + */ public boolean isEmpty() { return results.isEmpty(); } + /** + * @param result + * ResourceResult to add to this set + */ public void addResourceResult(final ResourceResult result) { results.add(result); } + /** + * @return number of ResourceResult objects contained in this set + */ public int getNumResults() { return results.size(); } + /** + * @param wmRequest + * @return the temporally closest ResourceResult object contained in this + * set to the exactTimestamp of the WMRequest argument. + */ public ResourceResult getClosest(final WMRequest wmRequest) { ResourceResult closest = null; *************** *** 52,59 **** --- 99,115 ---- } + /** + * @return an Iterator that contains the ResourceResult objects + */ public Iterator iterator() { return results.iterator(); } + /** + * unused presently, possibly useful in advanced QueryUI column + * generation... + * + * @return Arraylist of String years included in this set. + */ public ArrayList getYears() { ArrayList years = new ArrayList(); *************** *** 71,74 **** --- 127,137 ---- } + /** + * unused presently, possibly useful in advanced QueryUI column + * generation... + * + * @param year + * @return ArrayList of ResourceResult objects within the year argument. + */ public ArrayList resultsInYear(String year) { ArrayList resultsToReturn = new ArrayList(); *************** *** 83,86 **** --- 146,153 ---- } + /** + * @return the earliest Timestamp among all ResourceResult objects in this + * set. + */ public Timestamp firstTimestamp() { if (results.isEmpty()) { *************** *** 91,94 **** --- 158,165 ---- } + /** + * @return the latest Timestamp among all ResourceResult objects in this + * set. + */ public Timestamp lastTimestamp() { if (results.isEmpty()) { *************** *** 103,107 **** */ public static void main(String[] args) { - // TODO Auto-generated method stub } --- 174,177 ---- |