View Javadoc

1   /*
2    * 
3    * 
4    */
5   package earutils.expander;
6   
7   import java.io.*;
8   
9   /***
10   * 
11   * @author Sean C. Sullivan
12   * 
13   */
14  public class SimpleExpanderListener implements ExpanderListener
15  {
16  	private boolean verbose = false;
17  	private PrintStream stream;
18  	
19  	public SimpleExpanderListener(PrintStream ps, boolean verbose)
20  	{
21  		this.stream = ps;
22  		this.verbose = verbose;
23  	}
24  	
25  	public SimpleExpanderListener(boolean verbose)
26  	{
27  		this(System.out, verbose);
28  	}
29  
30  	public void expansionStarted(String archiveName)
31  	{
32  		if (verbose)
33  		{
34  			stream.println("Expanding: " + archiveName);
35  		}
36  	}
37  
38  	public void expansionFinished(String archiveName, 
39  				boolean success,
40  				long duration /* milliseconds */)
41  	{
42  		if (success)
43  		{
44  			stream.println("Expansion complete: "
45  					+ archiveName
46  					+ " ( "
47  					+ duration / 1000.0
48  					+ " seconds )");		
49  		}
50  		else
51  		{
52  			stream.println("Expansion finished with an error: " + archiveName);
53  		}
54  	}
55  
56  	public void entrySkipped(String entryName)
57  	{
58  		if (verbose)
59  		{
60  			stream.println("Ignoring entry: " + entryName);
61  		}
62  	}
63  
64  	public void fileCreated(String file)
65  	{
66  		if (verbose)
67  		{
68  			stream.println("File created: " + file);
69  		}
70  	}
71  
72  }