001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022/*
023 *    SimpleInputHandler.java
024 */
025package org.biojava.utils.process;
026
027import java.io.IOException;
028import java.io.InputStream;
029import java.util.logging.Logger;
030
031
032/**
033 * Simple {@linkplain org.biojava.utils.process.InputHandler input handler} 
034 * that reads the input for an external process from an 
035 * {@linkplain org.biojava.utils.process.StreamPipe#getInput() input stream}. The
036 * {@linkplain org.biojava.utils.process.StreamPipe#getOutput() output stream} for
037 * the input of the external process is closed after the input stream is read
038 * to its end.
039 * @author <a href="mailto:Martin.Szugat@GMX.net">Martin Szugat</a>
040 * @version $Revision$
041 */
042public final class SimpleInputHandler extends StreamPipe 
043implements InputHandler {
044    
045    /* STATIC FIELDS */
046    
047    /**
048     * The class logger.
049     */
050    private static final Logger LOGGER = 
051        Logger.getLogger(SimpleInputHandler.class.getName());
052
053    /* PUBLIC CONSTRUCTORS */
054    
055    /**
056     * Initializes the simple input handler.
057     * @param input the input stream from which to read the input for the 
058     * external process. May be <code>null</code>.
059     * @param tag a tag for logging. May be <code>null</code>.
060     */
061    public SimpleInputHandler(InputStream input, String tag) {
062        super(input, null, tag);
063    }
064    
065    /* INTERFACE Runnable */
066
067    /**
068     * {@inheritDoc}
069     */
070    public void run() {
071        super.run();
072        try {
073            getOutput().close();
074        } catch (IOException e) {
075            LOGGER.severe(e.toString());
076        }
077    }
078
079}