This class is unfinished. It was to display the results of the previous operations in an HTML browser window, using the default browser of the user's computer. But as it turned out, so few results were returned from the Internet Archive--and so prohibitive would it have been to sift the good results from false positives--that the project was scrapped.
Up side: I saved my department time and money by showing that this wasn't worth pursuing!
/**
*
*/
package iasearcher;
import java.io.*;
import java.util.*;
/**
* @author slittle2
*
* IAResults.java 1.0 displays an HTML page with the results of
* the IASearcher.java search. It divides the results into three
* parts: No hits, one hit, and multiple hits. Each gives the title
* and author of the work, plus links to search the IA full text
* and the CRRA record so that the user can compare the two. It also
* prints the IA "key" next to the links. The multiple results page
* displays the multiple results in a subordinate list.
*
* To do in the future: Generate HTML and open without having to save
* save to a file (unless having the HTML results is desirable?).
*
* Uses http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#browse%28java.net.URI%29
*
*/
public class IAResults{
/**
* @param args
*/
public static void main(String[] args) throws IOException {
/* Web page should look like this:
*
* Report 1 - No hits
* * Title/Author [(Search IA) (Search CRRA) ?]
* ...
*
* Report 2 - 1 hit
* * Title/Author (Search IA) (Search CRRA) (Key)
* ...
*
* Report 3 - Multiple hits
* * Title/Author
* * (Search IA) (Search CRRA) (Key)
* * (Search IA) (Search CRRA) (Key)
* ...
*
*
* Basic code:
*
* <html>
*
* <body>
*
* <h1>Report 1 - No hits</h1>
* <ul>
* <li>Title/Author</li>
* ... (more results)
* </ul>
*
* <h1>Report 2 - 1 hit</h1>
* <ul>
* <li>Title/Author (Search IA) (Search CRRA) (Key)</li>
* ... (more results)
* </ul>
*
* <h1>Report 3 - Multiple hits</h1>
* <ul>
* <li>Title/Author
* <ul>
* <li>(Search IA) (Search CRRA) (Key)</li>
* ... (more results)
* </ul>
* </li>
* ... (more results)
* </ul>
*
* </body>
*
* </html>
*
*/
// Initialize variables
BufferedReader noResultsFile = null;
BufferedReader oneResultFile = null;
BufferedReader manyResultsFile = null;
LinkedHashSet noResultsSet = new LinkedHashSet(); // Sets to import the results data into
LinkedHashSet oneResultSet = new LinkedHashSet();
LinkedHashSet manyResultsSet = new LinkedHashSet();
String data = " "; // Generic variable used for reading Strings
// Open files and load results into appropriate sets
try {
noResultsFile = new BufferedReader((Reader) new FileReader("C:/Documents and Settings/slittle2/workspace/MarcRetriever/noResults.txt"));
oneResultFile = new BufferedReader((Reader) new FileReader("C:/Documents and Settings/slittle2/workspace/MarcRetriever/oneResult.txt"));
manyResultsFile = new BufferedReader((Reader) new FileReader("C:/Documents and Settings/slittle2/workspace/MarcRetriever/manyResults.txt"));
while ((data = noResultsFile.readLine()) != null) {
noResultsSet.add(data);
}
while ((data = oneResultFile.readLine()) != null) {
oneResultSet.add(data);
}
while ((data = manyResultsFile.readLine()) != null) {
manyResultsSet.add(data);
}
// System.out.println(noResultsSet.toString()); TODO remove test code
// System.out.println(oneResultSet.toString());
// System.out.println(manyResultsSet.toString());
}catch (FileNotFoundException e){
System.err.println("*** File Not Found ***");
e.getStackTrace();
}finally{
if(noResultsFile != null) noResultsFile.close();
if(oneResultFile != null) oneResultFile.close();
if(manyResultsFile != null) manyResultsFile.close();
}
// Output strings into a single HTML file
Iterator iter = noResultsSet.iterator(); // TODO find author/title pairs
while(iter.hasNext()){
data = (String) iter.next();
System.out.println(data); // TODO remove test code
}
iter = oneResultSet.iterator(); // TODO find author/title pairs
while(iter.hasNext()){
data = (String) iter.next();
System.out.println(data); // TODO remove test code
}
iter = manyResultsSet.iterator(); // TODO find author/title pairs; break down strings into substrings
while(iter.hasNext()){
data = (String) iter.next();
System.out.println(data); // TODO remove test code
}
// Open HTML file with .awt.Desktop class
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment