org.edg.data.util
Class CommandBase

java.lang.Object
  |
  +--org.edg.data.util.CommandBase
All Implemented Interfaces:
Command

public abstract class CommandBase
extends java.lang.Object
implements Command

The base class for each command, dealing with the option parsing and help messages (the common base tasks).

Version:
$Id: CommandBase.java,v 1.24 2004/05/18 10:32:33 jamesc Exp $
Author:
Peter Kunszt

Constructor Summary
protected CommandBase(java.lang.String programName, java.lang.String commandName, java.lang.String[] commandArgs)
           
 
Method Summary
protected  void addArgument(int position, java.lang.String name, java.lang.String description)
           
protected  void addOption(org.apache.commons.cli.Option opt)
           
protected  void description(java.lang.String desc)
           
abstract  boolean execute()
          Execute the command.
protected  java.lang.String getArgument(java.lang.String name)
           
 boolean getBoolOption(java.lang.String option)
           
protected  org.apache.commons.cli.CommandLine getCommandLine()
          return the parsed command line
protected  java.lang.String getCommandName()
           
 java.lang.String getConfigFile()
           
protected  org.apache.commons.cli.Options getOptions()
           
 java.lang.String getStringOption(java.lang.String option)
           
 java.lang.String getVO()
           
protected abstract  void init()
          do the per command initialization of each command's options
 boolean isSecure()
           
 boolean isVerbose()
           
 void printHelp()
          print help on command
 void setOption(java.util.HashMap opt)
           
 void setVerbose(boolean isVerbose)
           
protected static java.lang.String stripGuidPrefix(java.lang.String guid)
           
protected static java.lang.String stripGuidPrefixes(java.lang.String query)
          given a query, which might contain some queries on the guid_guid column, remove guid: prefixes from those gueries
protected static java.lang.String stripLfnPrefix(java.lang.String lfn)
           
protected static java.lang.String stripLfnPrefixes(java.lang.String query)
          given a query, which might contain some queries on the lfn_lfn column, remove lfn: prefixes from those gueries
protected static java.lang.String withGuidPrefix(java.lang.String guid)
           
protected static java.lang.String withLfnPrefix(java.lang.String lfn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandBase

protected CommandBase(java.lang.String programName,
                      java.lang.String commandName,
                      java.lang.String[] commandArgs)
               throws CommandLineException
Method Detail

addOption

protected void addOption(org.apache.commons.cli.Option opt)

getCommandLine

protected org.apache.commons.cli.CommandLine getCommandLine()
return the parsed command line

Returns:
the command line

getOptions

protected org.apache.commons.cli.Options getOptions()

getCommandName

protected java.lang.String getCommandName()

addArgument

protected void addArgument(int position,
                           java.lang.String name,
                           java.lang.String description)

description

protected void description(java.lang.String desc)

getArgument

protected java.lang.String getArgument(java.lang.String name)
                                throws CommandLineException
CommandLineException

setVerbose

public void setVerbose(boolean isVerbose)

isVerbose

public boolean isVerbose()
Specified by:
isVerbose in interface Command

isSecure

public boolean isSecure()
Specified by:
isSecure in interface Command

getVO

public java.lang.String getVO()
Specified by:
getVO in interface Command

getConfigFile

public java.lang.String getConfigFile()
Specified by:
getConfigFile in interface Command

stripGuidPrefix

protected static final java.lang.String stripGuidPrefix(java.lang.String guid)

withGuidPrefix

protected static final java.lang.String withGuidPrefix(java.lang.String guid)

stripGuidPrefixes

protected static final java.lang.String stripGuidPrefixes(java.lang.String query)
given a query, which might contain some queries on the guid_guid column, remove guid: prefixes from those gueries

Parameters:
query -
Returns:
the query, without the guid: prefixes

stripLfnPrefix

protected static final java.lang.String stripLfnPrefix(java.lang.String lfn)

withLfnPrefix

protected static final java.lang.String withLfnPrefix(java.lang.String lfn)

stripLfnPrefixes

protected static final java.lang.String stripLfnPrefixes(java.lang.String query)
given a query, which might contain some queries on the lfn_lfn column, remove lfn: prefixes from those gueries

Parameters:
query -
Returns:
the query, without the lfn: prefixes

printHelp

public void printHelp()
print help on command

Specified by:
printHelp in interface Command

setOption

public void setOption(java.util.HashMap opt)
               throws CommandLineException
CommandLineException

getStringOption

public java.lang.String getStringOption(java.lang.String option)

getBoolOption

public boolean getBoolOption(java.lang.String option)

init

protected abstract void init()
do the per command initialization of each command's options


execute

public abstract boolean execute()
                         throws DataException
Description copied from interface: Command
Execute the command.

Specified by:
execute in interface Command
DataException