org.at4j.support.prog
Class AbstractProgram

java.lang.Object
  extended by org.at4j.support.prog.AbstractProgram
Direct Known Subclasses:
AbstractStreamCompressionProgram, Lzma, Tar, UnLzma, Unzip, Zip

public abstract class AbstractProgram
extends Object

This is an abstract base class for command-line programs such as zip, unzip and tar. It contains common utility functions.

Since:
1.0
Author:
Karl Gustafsson

Constructor Summary
AbstractProgram()
           
 
Method Summary
protected  String getArg(String[] args, int pos, String errMsg)
          Get the argument from the specified position.
protected  AbsoluteLocation getParentLocation(File f)
          Get the absolute location of the file's parent directory.
protected  boolean isFlagArgument(String arg)
          Is the argument a flag argument, i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractProgram

public AbstractProgram()
Method Detail

getArg

protected String getArg(String[] args,
                        int pos,
                        String errMsg)
                 throws CommandErrorException
Get the argument from the specified position. If the position is beyond the end of the argument array, throw a CommandErrorException having the supplied error message.

Parameters:
args - The argument array.
pos - The position in the array of the argument.
errMsg - The error message to use for the exception if the position is beyond the end of the array.
Returns:
The argument value.
Throws:
CommandErrorException - If the position is beyond the end of the array.

isFlagArgument

protected boolean isFlagArgument(String arg)
Is the argument a flag argument, i.e. does it start with a -?

Parameters:
arg - The argument.
Returns:
true if the argument is a flag argument.

getParentLocation

protected AbsoluteLocation getParentLocation(File f)
Get the absolute location of the file's parent directory.

Parameters:
f - The file
Returns:
The location of the file's parent directory.