Package org.apache.zookeeper.cli
Class CliCommand
- java.lang.Object
- 
- org.apache.zookeeper.cli.CliCommand
 
- 
- Direct Known Subclasses:
- AddAuthCommand,- AddWatchCommand,- CloseCommand,- CreateCommand,- DeleteAllCommand,- DeleteCommand,- DelQuotaCommand,- GetAclCommand,- GetAllChildrenNumberCommand,- GetCommand,- GetConfigCommand,- GetEphemeralsCommand,- ListQuotaCommand,- LsCommand,- ReconfigCommand,- RemoveWatchesCommand,- SetAclCommand,- SetCommand,- SetQuotaCommand,- StatCommand,- SyncCommand,- VersionCommand,- WhoAmICommand
 
 public abstract class CliCommand extends Object base class for all CLI commands
- 
- 
Field SummaryFields Modifier and Type Field Description protected PrintStreamerrprotected PrintStreamoutprotected ZooKeeperzk
 - 
Constructor SummaryConstructors Constructor Description CliCommand(String cmdStr, String optionStr)a CLI command with command string and options.CliCommand(String cmdStr, String optionStr, org.apache.commons.cli.Options options)a CLI command with command string and options.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddToMap(Map<String,CliCommand> cmdMap)add this command to a map.abstract booleanexec()StringgetCmdStr()get the string used to call this commandStringgetOptionStr()get the option stringStringgetUsageStr()get a usage string, contains the command and the optionsabstract CliCommandparse(String[] cmdArgs)parse the command argumentsvoidsetErr(PrintStream err)Set err printStream (usable for testing)voidsetOut(PrintStream out)Set out printStream (usable for testing)voidsetZk(ZooKeeper zk)set the zookeeper instance
 
- 
- 
- 
Field Detail- 
zkprotected ZooKeeper zk 
 - 
outprotected PrintStream out 
 - 
errprotected PrintStream err 
 
- 
 - 
Constructor Detail- 
CliCommandpublic CliCommand(String cmdStr, String optionStr) a CLI command with command string and options. Using System.out and System.err for printing- Parameters:
- cmdStr- the string used to call this command
- optionStr- the string used to call this command
 
 - 
CliCommandpublic CliCommand(String cmdStr, String optionStr, org.apache.commons.cli.Options options) a CLI command with command string and options. Using System.out and System.err for printing- Parameters:
- cmdStr- the string used to call this command
- optionStr- the string used to call this command
- options- the command options
 
 
- 
 - 
Method Detail- 
setOutpublic void setOut(PrintStream out) Set out printStream (usable for testing)- Parameters:
- out-
 
 - 
setErrpublic void setErr(PrintStream err) Set err printStream (usable for testing)- Parameters:
- err-
 
 - 
setZkpublic void setZk(ZooKeeper zk) set the zookeeper instance- Parameters:
- zk- the ZooKeeper instance.
 
 - 
getCmdStrpublic String getCmdStr() get the string used to call this command
 - 
getOptionStrpublic String getOptionStr() get the option string
 - 
getUsageStrpublic String getUsageStr() get a usage string, contains the command and the options
 - 
addToMappublic void addToMap(Map<String,CliCommand> cmdMap) add this command to a map. Use the command string as key.- Parameters:
- cmdMap-
 
 - 
parsepublic abstract CliCommand parse(String[] cmdArgs) throws CliParseException parse the command arguments- Parameters:
- cmdArgs-
- Returns:
- this CliCommand
- Throws:
- CliParseException
 
 - 
execpublic abstract boolean exec() throws CliException- Returns:
- true if command has watch option, false otherwise
- Throws:
- CliException
 
 
- 
 
-