TrueZIP 6.8.3

de.schlichtherle.io.samples
Class CommandLineUtility

java.lang.Object
  extended by de.schlichtherle.io.samples.CommandLineUtility
Direct Known Subclasses:
Decrypt, Encrypt, NZip

abstract class CommandLineUtility
extends Object

Abstract base class for command line utilities.

Since:
TrueZIP 6.5
Author:
Christian Schlichtherle

Nested Class Summary
protected static class CommandLineUtility.IllegalUsageException
           
protected static class CommandLineUtility.ProgressMonitor
           
 
Field Summary
protected  PrintStream err
          The print stream for error output.
protected  PrintStream out
          The print stream for standard output.
protected  CommandLineUtility.ProgressMonitor progressMonitor
          The command line progress monitor.
 
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 configKeyManager()
          Configure the key manager to use when prompting the user for keys for RAES encrypted ZIP files.
 int run(String[] args)
          Runs this command line utility.
abstract  boolean runWithException(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.


progressMonitor

protected final CommandLineUtility.ProgressMonitor progressMonitor
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.

Warning: This constructor has side effects: If Swing based prompting is used, the Hurling Window Feedback is set for feedback on wrong key entry unless the respective system properties have been explicitly set.

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.
See Also:
PromptingKeyManager
Method Detail

configKeyManager

private static void configKeyManager()
Configure the key manager to use when prompting the user for keys for RAES encrypted ZIP files.


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.

runWithException

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

Parameters:
args - A non-empty array of Unix-like commands and optional parameters.
Returns:
false iff the command is a test which fails, true otherwise.
Throws:
CommandLineUtility.IllegalUsageException - If args does not contain correct commands or parameters.
IOException - On any I/O related exception.

TrueZIP 6.8.3

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