Revision: 2710 http://archive-access.svn.sourceforge.net/archive-access/?rev=2710&view=rev Author: bradtofel Date: 2009-05-20 01:53:51 +0000 (Wed, 20 May 2009) Log Message: ----------- REFACTOR: changed modifiers of methods and instance variables. Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java 2009-05-20 01:40:58 UTC (rev 2709) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/requestparser/BaseRequestParser.java 2009-05-20 01:53:51 UTC (rev 2710) @@ -31,44 +31,42 @@ import org.archive.wayback.RequestParser; import org.archive.wayback.core.WaybackRequest; import org.archive.wayback.exception.BadQueryException; +import org.archive.wayback.exception.BetterRequestException; import org.archive.wayback.util.Timestamp; import org.archive.wayback.webapp.AccessPoint; /** - * Class that implements the RequestParser interface, and also understands how - * to: + * Abstract implementation of the RequestParser interface, which provides some + * convenience methods for accessing data in Map<String,String>'s, and also + * allows for configuring maxRecords, and earliest and latest timestamp strings. * - * - * This class will attempt to use the overridable parseCustom() method to - * create the WaybackRequest object, but if that fails (returns null), it will - * fall back to: - - * A) attempting to parse out an incoming OpenSearch format query - * B) attempting to parse out any and all incoming form elements submitted as - * either GET or POST arguments + * Subclasses must still implement parse(). * - * This class also contains the functionality to extract HTTP header - * information into WaybackRequest objects, including Http auth info, referer, - * remote IPs, etc. - * * @author brad * @version $Date$, $Revision$ */ public abstract class BaseRequestParser implements RequestParser { - protected final static String QUERY_BASE = "query"; + public final static String QUERY_BASE = "query"; - protected final static String XQUERY_BASE = "xmlquery"; + public final static String XQUERY_BASE = "xmlquery"; - protected final static String REPLAY_BASE = "replay"; + public final static String REPLAY_BASE = "replay"; - protected final static int DEFAULT_MAX_RECORDS = 10; + public final static int DEFAULT_MAX_RECORDS = 10; - protected int maxRecords = DEFAULT_MAX_RECORDS; - protected String earliestTimestamp = null; - protected String latestTimestamp = null; + private int maxRecords = DEFAULT_MAX_RECORDS; + private String earliestTimestamp = null; + private String latestTimestamp = null; + /* (non-Javadoc) + * @see org.archive.wayback.RequestParser#parse(javax.servlet.http.HttpServletRequest) + */ + public abstract WaybackRequest parse(HttpServletRequest httpRequest, + AccessPoint wbContext) throws BadQueryException, + BetterRequestException; + protected static String getMapParam(Map<String,String[]> queryMap, String field) { String arr[] = queryMap.get(field); @@ -97,12 +95,6 @@ return (val == null) ? "" : val; } - /* (non-Javadoc) - * @see org.archive.wayback.RequestParser#parse(javax.servlet.http.HttpServletRequest) - */ - public abstract WaybackRequest parse(HttpServletRequest httpRequest, - AccessPoint wbContext) throws BadQueryException; - /** * @return the maxRecords */ @@ -116,23 +108,31 @@ public void setMaxRecords(int maxRecords) { this.maxRecords = maxRecords; } + /** - * @param timestamp + * @param default earliest timestamp */ public void setEarliestTimestamp(String timestamp) { earliestTimestamp = Timestamp.parseBefore(timestamp).getDateStr(); } + /** - * @return + * @return the default earliest timestamp */ public String getEarliestTimestamp() { return earliestTimestamp; } + /** + * @param default latest timestamp + */ public String getLatestTimestamp() { return latestTimestamp; } + /** + * @return the default latest timestamp + */ public void setLatestTimestamp(String timestamp) { this.latestTimestamp = Timestamp.parseAfter(timestamp).getDateStr(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |