package streams;

import java.io.*;
import java.util.*;

/**
 * A factory for constructing pairs of "piped streams"
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class PipedStreamFactory
{
    private PipedInputStream  in;
    private PipedOutputStream out;
    
    /**
     * Default Constructor
     */
    public PipedStreamFactory()
    {
       try 
       {
          in  = new PipedInputStream();
          out = new PipedOutputStream(in);
       }
       catch (IOException ioe) 
       {
          in  = null;
          out = null;          
       }
    }
    


    /**
     * Get the PipedInputStream
     *
     * @return       The PipedInputStream
     */
    public PipedInputStream getInputStream() throws IOException
    {
       if (in == null) throw new IOException();
       
       return in;
    }




    /**
     * Get the PipedOutputStream
     *
     * @return       The PipedOutputStream
     */
    public PipedOutputStream getOutputStream() throws IOException
    {
       if (out == null) throw new IOException();
       
       return out;
    }


}
