TrueZIP Samples 7.0-rc2

de.schlichtherle.truezip.sample.file.app
Class CommandLineUtility

java.lang.Object
  extended by de.schlichtherle.truezip.sample.file.app.CommandLineUtility
Direct Known Subclasses:
Decrypt, Encrypt, Nzip, PathCat, Pickr, UriCat

abstract class CommandLineUtility
extends Object

Abstract base class for command line utilities.

Author:
Christian Schlichtherle

Nested Class Summary
protected static class CommandLineUtility.IllegalUsageException
          Indicates illegal application parameters.
protected static class CommandLineUtility.ProgressMonitor
          Monitors progress when committing unsynchronized changes to the contents of archive files.
 
Field Summary
protected  PrintStream err
          The print stream for error output.
protected  CommandLineUtility.ProgressMonitor monitor
          The command line progress monitor.
protected  PrintStream out
          The print stream for standard output.
 
Constructor Summary
protected CommandLineUtility()
          Equivalent to CommandLineUtility(System.out, System.err, true).
protected CommandLineUtility(OutputStream out, OutputStream err, boolean autoFlush)
          Constructs a new command line utility instance.
 
Method Summary
private static void configureFeedback()
          Configure the type of the feedback when prompting the user for keys for RAES encrypted ZIP files using the Swing based prompting key manager.
private static void configureManagerService()
           
 int run(String[] args)
          Runs this command line utility.
abstract  int runChecked(String[] args)
          Runs this command line utility.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected final PrintStream out
The print stream for standard output.


err

protected final PrintStream err
The print stream for error output.


monitor

protected final CommandLineUtility.ProgressMonitor monitor
The command line progress monitor.

Constructor Detail

CommandLineUtility

protected CommandLineUtility()
Equivalent to CommandLineUtility(System.out, System.err, true).


CommandLineUtility

protected CommandLineUtility(OutputStream out,
                             OutputStream err,
                             boolean autoFlush)
Constructs a new command line utility instance.

Note that this constructor has side effects:

Parameters:
out - the standard output stream.
err - the error output stream.
autoFlush - if the output streams are not PrintStreams, then they are wrapped in a new PrintStream with this as the additional constructor parameter.
Method Detail

configureFeedback

private static void configureFeedback()
Configure the type of the feedback when prompting the user for keys for RAES encrypted ZIP files using the Swing based prompting key manager. If this JVM is running in headless mode, then the configuration is ignored.


configureManagerService

private static void configureManagerService()

run

public final int run(String[] args)
Runs this command line utility. Prints a user readable error message to the error output stream which was provided to the constructor if an error occurs.

Parameters:
args - A non-empty array of Unix-like commands and optional parameters.
Returns:
1 iff the command fails, 0 otherwise.

runChecked

public abstract int runChecked(String[] args)
                        throws CommandLineUtility.IllegalUsageException,
                               IOException
Runs this command line utility. Throws an exception if an error occurs.

Parameters:
args - a non-null array of command line parameters.
Returns:
the return code for System.exit(int).
Throws:
CommandLineUtility.IllegalUsageException - If args does not contain correct commands or parameters.
IOException - On any I/O related exception.

TrueZIP Samples 7.0-rc2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.