View Javadoc

1   package net.sf.jpkgmk;
2   
3   import java.io.File;
4   import java.io.IOException;
5   
6   import net.sf.jpkgmk.FileHandler.ContentWriter;
7   
8   /**
9    * Abstract implementation of the {@link ContentWriter} interface to create a file
10   * @author gommma (gommma AT users.sourceforge.net)
11   * @author Last changed by: $Author: gommma $
12   * @version $Revision: 2 $ $Date: 2008-08-20 21:14:19 +0200 (Mi, 20 Aug 2008) $
13   * @since 1.0
14   */
15  public abstract class AbstractFileCreatorAdapter implements ContentWriter
16  {
17  
18  	public abstract FileHandler getFileHandler(File targetDir);
19  	
20  	/**
21  	 * Creates the one file represented by this file creator in the given target directory.
22  	 * This might be a prototype, pkgmap, pkginfo or something arbitrary different
23  	 * @param targetDir The directory into which the file will be written
24  	 * @throws IOException
25  	 */
26  	public void create(File targetDir) throws IOException
27  	{
28  		FileHandler fileCreator = getFileHandler(targetDir);
29  		FileHandler.ContentWriter contentWriter = this;
30  		fileCreator.create(contentWriter);
31  	}
32  
33  	public void clean(File targetDir)
34  	{
35  		FileHandler fileCreator = getFileHandler(targetDir);
36  		fileCreator.clean();
37  	}
38  }