org.kohsuke.args4j.opts
Class BooleanOption

java.lang.Object
  extended by org.kohsuke.args4j.opts.BooleanOption
All Implemented Interfaces:
CmdLineOption

public class BooleanOption
extends java.lang.Object
implements CmdLineOption

Boolean option. The presence of the option sets the flag. Also, it recognized -opt- -opt+ to turn on/off the flag respectively.

Author:
Kohsuke Kawaguchi (kk@kohsuke.org)

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.kohsuke.args4j.CmdLineOption
CmdLineOption.Parameters
 
Field Summary
private  java.lang.String optionName
           
 boolean value
          Value of this option.
 
Constructor Summary
BooleanOption(java.lang.String optionName)
           
BooleanOption(java.lang.String optionName, boolean defaultValue)
           
 
Method Summary
 boolean accepts(java.lang.String optionName)
          Checks if this option parser recognizes the specified option name.
 boolean isOff()
          Returns true if this switch is off.
 boolean isOn()
          Returns true if this switch is on.
 int parseArguments(CmdLineParser parser, CmdLineOption.Parameters params)
          Called if the option that this parser recognizes is found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

optionName

private final java.lang.String optionName

value

public boolean value
Value of this option.

Constructor Detail

BooleanOption

public BooleanOption(java.lang.String optionName)

BooleanOption

public BooleanOption(java.lang.String optionName,
                     boolean defaultValue)
Method Detail

accepts

public boolean accepts(java.lang.String optionName)
Description copied from interface: CmdLineOption
Checks if this option parser recognizes the specified option name.

Specified by:
accepts in interface CmdLineOption

parseArguments

public int parseArguments(CmdLineParser parser,
                          CmdLineOption.Parameters params)
                   throws CmdLineException
Description copied from interface: CmdLineOption
Called if the option that this parser recognizes is found.

Specified by:
parseArguments in interface CmdLineOption
Parameters:
parser - The parser that's using this option object. For example, if the option "-quiet" is simply an alias to "-verbose 5", then the implementation can just call the CmdLineParser.parse(String[]) method recursively.
params - The rest of the arguments. This method can use this object to access the arguments of the option if necessary.
Returns:
The number of arguments consumed. For example, return 0 if this option doesn't take any parameter.
Throws:
CmdLineException

isOn

public final boolean isOn()
Returns true if this switch is on.


isOff

public final boolean isOff()
Returns true if this switch is off.



Copyright © 2003 Kohsuke Kawaguchi. All Rights Reserved.