Revision: 2525 http://archive-access.svn.sourceforge.net/archive-access/?rev=2525&view=rev Author: bradtofel Date: 2008-08-07 22:00:34 +0000 (Thu, 07 Aug 2008) Log Message: ----------- INITIAL-REV: flat file partial implementation of the locationDB, does not support any of the indexing features - add, remove, and mark-related methods. Added Paths: ----------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java Added: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java (rev 0) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java 2008-08-07 22:00:34 UTC (rev 2525) @@ -0,0 +1,88 @@ +package org.archive.wayback.resourcestore.locationdb; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; + +import org.archive.wayback.util.CloseableIterator; +import org.archive.wayback.util.flatfile.FlatFile; + +public class FlatFileResourceFileLocationDB implements ResourceFileLocationDB { + private String path = null; + private FlatFile flatFile = null; + private String delimiter = "\t"; + + + public void addNameUrl(String name, String url) throws IOException { + // NO-OP + } + + public long getCurrentMark() throws IOException { + return 0; + } + + public CloseableIterator<String> getNamesBetweenMarks(long start, long end) + throws IOException { + return null; + } + + public String[] nameToUrls(String name) throws IOException { + ArrayList<String> urls = new ArrayList<String>(); + String prefix = name + delimiter; + Iterator<String> itr = flatFile.getRecordIterator(prefix); + while(itr.hasNext()) { + String line = itr.next(); + if(line.startsWith(prefix)) { + urls.add(line.substring(prefix.length())); + } else { + break; + } + } + if(itr instanceof CloseableIterator) { + CloseableIterator<String> citr = (CloseableIterator<String>) itr; + citr.close(); + } + String[] a = new String[urls.size()]; + for(int i=0; i < urls.size(); i++) { + a[i] = urls.get(i); + } + return a; + } + + public void removeNameUrl(String name, String url) throws IOException { + // NO-OP + } + + public void shutdown() throws IOException { + // NO-OP + } + + /** + * @param path the path to set + */ + public void setPath(String path) { + this.path = path; + flatFile = new FlatFile(path); + } + + /** + * @return the path + */ + public String getPath() { + return path; + } + + /** + * @param delimter the delimiter to set + */ + public void setDelimiter(String delimiter) { + this.delimiter = delimiter; + } + + /** + * @return the delimiter + */ + public String getDelimiter() { + return delimiter; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 2915 http://archive-access.svn.sourceforge.net/archive-access/?rev=2915&view=rev Author: bradtofel Date: 2009-11-08 00:42:59 +0000 (Sun, 08 Nov 2009) Log Message: ----------- CLEANUP: added @SuppressWarnings Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java 2009-11-08 00:42:12 UTC (rev 2914) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java 2009-11-08 00:42:59 UTC (rev 2915) @@ -50,6 +50,7 @@ return null; } + @SuppressWarnings("unchecked") public String[] nameToUrls(String name) throws IOException { ArrayList<String> urls = new ArrayList<String>(); String prefix = name + delimiter; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 3517 http://archive-access.svn.sourceforge.net/archive-access/?rev=3517&view=rev Author: bradtofel Date: 2011-09-06 03:49:59 +0000 (Tue, 06 Sep 2011) Log Message: ----------- LOGGING Modified Paths: -------------- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java Modified: trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java =================================================================== --- trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java 2011-09-06 03:49:28 UTC (rev 3516) +++ trunk/archive-access/projects/wayback/wayback-core/src/main/java/org/archive/wayback/resourcestore/locationdb/FlatFileResourceFileLocationDB.java 2011-09-06 03:49:59 UTC (rev 3517) @@ -22,11 +22,14 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; +import java.util.logging.Logger; import org.archive.wayback.util.CloseableIterator; import org.archive.wayback.util.flatfile.FlatFile; public class FlatFileResourceFileLocationDB implements ResourceFileLocationDB { + private final static Logger LOGGER = + Logger.getLogger(FlatFileResourceFileLocationDB.class.getName()); private String path = null; private FlatFile flatFile = null; private String delimiter = "\t"; @@ -62,6 +65,9 @@ CloseableIterator<String> citr = (CloseableIterator<String>) itr; citr.close(); } + if(urls.size() == 0) { + LOGGER.warning("No locations for " + name + " in " + path); + } String[] a = new String[urls.size()]; for(int i=0; i < urls.size(); i++) { a[i] = urls.get(i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |