/*
    PCS - A Framework For Java Web Applications
    Copyright (C) 2002 Patrick Carl, patrick.carl@web.de
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
 
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
    $Id: JTidyThread.java,v 1.2 2003/01/08 02:37:00 pcs_org Exp $
 
 */

package de.spieleck.pcs.view;

import java.io.InputStream;
import java.io.OutputStream;

import org.w3c.tidy.Tidy;

/**
 * This class encapsulates the tidying of the transformed HTML in an own 
 * Thread
 * @author  Patrick Carl
 */
public class JTidyThread extends Thread {
    
    /** Holds value of property in. */
    private InputStream in;    
    
    /** Holds value of property out. */
    private OutputStream out;    
    
    private Tidy tidy;
    
    /** Creates a new instance of JTidyThread */
    public JTidyThread(InputStream in, OutputStream out) {
        setIn(in);
        setOut(out);
        tidy = new Tidy();
        tidy.setXHTML(true);
        tidy.setQuiet(true);
    }

    /**
     * parses the InputStream with JTidy and writes it to the OutputStream
     */
    public void run() {
        tidy.parse(getIn(), getOut());
    }
    
    /** Getter for property in.
     * @return Value of property in.
     *
     */
    public InputStream getIn() {
        return this.in;
    }
    
    /** Setter for property in.
     * @param in New value of property in.
     *
     */
    public void setIn(InputStream in) {
        this.in = in;
    }
    
    /** Getter for property out.
     * @return Value of property out.
     *
     */
    public OutputStream getOut() {
        return this.out;
    }
    
    /** Setter for property out.
     * @param out New value of property out.
     *
     */
    public void setOut(OutputStream out) {
        this.out = out;
    }
    
}