 /*
 * Copyright (C) 11-sept.-2003  Jean-Yves Beaujean 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * This program 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 General Public License for
 * more details.
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,  59
 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 * 
 */
package jxtray.io;

import java.io.IOException;



/**
 * 
 * @author Jean-Yves Beaujean
 *  This class represent the context of the writer action.
 *  WriterStrategy object is set according to the context : Jar, Zip, 
 *   All set methods must be used to set this object.
 */
public class WriterContext 
{
		private WriterStrategy strategy = null;
		
		public WriterContext(String filename)
		{
			setPlainTextWriterStrategy(filename);
		} 
		
		public void setPlainTextWriterStrategy(String filename)
		{
				strategy = new PlainTextWriterStrategy(filename);
		}
		public void setZipWriterStrategy(String filename)
		{
				strategy = new ZipWriterStrategy(filename);
		}		
		
		public void setGunzipWriterStrategy(String filename)
		{
				strategy = new GunzipWriterStrategy(filename);
		}
		
		public void setJarWriterStrategy(String filename)
		{
					strategy = new JarWriterStrategy(filename);
		}
		
		public void write( String data) throws IOException
		{
				strategy.write(data);
		}
		
		public void close() throws IOException
		{
				strategy.close();
		}
		
		public void  open() throws IOException
		{
				strategy.open();
		}		
				
}
