import java.io.*;

import streams.Googler;
import streams.PipedStreamFactory;


/**
 * A driver for the Googler class.
 *
 * This version allows for line-by-line prompting
 * by using PipedStream objects
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison University
 */
public class GooglerDriver2
{
    /**
     * The entry point
     *
     * @param args   The command-line arguments
     */
    public static void main(String[] args) throws IOException
    {
	DataInputStream    console, dis;
	Googler            googler;
	PipedInputStream   pin;
	PipedOutputStream  pout;
        PipedStreamFactory factory;        
	PrintStream        out;
	String             line;


        factory = new PipedStreamFactory();        
	pin     = factory.getInputStream();
	pout    = factory.getOutputStream();

	console = new DataInputStream(System.in);
	dis     = new DataInputStream(pin);

	out     = new PrintStream(pout);

	googler = new Googler(dis);
        googler.start();
        
        System.out.print("Search for: ");
	while ((line = console.readLine()) != null)
        {
           out.println(line);
           System.out.print("Search for: ");
	}
    }
    

}
