com.syncbuilder.util.getopt
Class LongOpt

java.lang.Object
  |
  +--com.syncbuilder.util.getopt.LongOpt
Direct Known Subclasses:
FlagOpt, NumericalOpt, StringOpt

public class LongOpt
extends java.lang.Object

This is the base class for the more specialized types of options. You should not use this class directly.

See Also:
Getopt

Field Summary
protected  boolean _secret
          Should this option be mentioned to the public?
protected  boolean auto_default
           
protected  java.lang.String defaultval
           
protected  java.lang.String description
           
protected  java.lang.StringBuffer flag
          If this variable is not null, then the value stored in "val" is stored here when this long option is encountered.
protected  int has_arg
          Indicates whether the option has no argument, a required argument, or an optional argument.
protected  java.lang.String name
          The name of the long option
static int NO_ARGUMENT
          Constant value used for the "has_arg" constructor argument.
static int OPTIONAL_ARGUMENT
          Constant value used for the "has_arg" constructor argument.
static int REQUIRED_ARGUMENT
          Constant value used for the "has_arg" constructor argument.
protected  int val
          The value to store in "flag" if flag is not null, otherwise the equivalent short option character for this long option.
 
Constructor Summary
LongOpt(java.lang.String name, java.lang.String description, java.lang.String defaultval, boolean auto_default, int has_arg, java.lang.StringBuffer flag, int val)
          Create a new LongOpt object with the given parameter values.
 
Method Summary
 boolean getAutoDefault()
           
 java.lang.String getDefault()
           
 java.lang.String getDescription()
          Returns the description of this LongOpt as a String
 java.lang.StringBuffer getFlag()
          Returns the value of the 'flag' field for this long option
 int getHasArg()
          Returns the value set for the 'has_arg' field for this long option
 java.lang.String getName()
          Returns the name of this LongOpt as a String
 java.lang.String getPureDescription()
          Return the pure, undecorated value of the description-attribute.
 int getVal()
          Returns the value of the 'val' field for this long option
 boolean isSecret()
           
 void setSecret(boolean secret)
           
 boolean validateArgument(java.lang.String value)
          Validates the value of the option's argument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ARGUMENT

public static final int NO_ARGUMENT
Constant value used for the "has_arg" constructor argument. This value indicates that the option takes no argument.

REQUIRED_ARGUMENT

public static final int REQUIRED_ARGUMENT
Constant value used for the "has_arg" constructor argument. This value indicates that the option takes an argument that is required.

OPTIONAL_ARGUMENT

public static final int OPTIONAL_ARGUMENT
Constant value used for the "has_arg" constructor argument. This value indicates that the option takes an argument that is optional.

name

protected java.lang.String name
The name of the long option

description

protected java.lang.String description

defaultval

protected java.lang.String defaultval

auto_default

protected boolean auto_default

has_arg

protected int has_arg
Indicates whether the option has no argument, a required argument, or an optional argument.

flag

protected java.lang.StringBuffer flag
If this variable is not null, then the value stored in "val" is stored here when this long option is encountered. If this is null, the value stored in "val" is treated as the name of an equivalent short option.

val

protected int val
The value to store in "flag" if flag is not null, otherwise the equivalent short option character for this long option.

_secret

protected boolean _secret
Should this option be mentioned to the public? This particularly for GUIs.
Constructor Detail

LongOpt

public LongOpt(java.lang.String name,
               java.lang.String description,
               java.lang.String defaultval,
               boolean auto_default,
               int has_arg,
               java.lang.StringBuffer flag,
               int val)
        throws java.lang.IllegalArgumentException
Create a new LongOpt object with the given parameter values. If the value passed as has_arg is not valid, then an exception is thrown.
Parameters:
name - The long option String.
description - A verbal description of the purpose of this parameter
defaultval - A default value for this parameter, or null
has_arg - Indicates whether the option has no argument (NO_ARGUMENT), a required argument (REQUIRED_ARGUMENT) or an optional argument (OPTIONAL_ARGUMENT).
flag - If non-null, this is a location to store the value of "val" when this option is encountered, otherwise "val" is treated as the equivalent short option character.
val - The value to return for this long option, or the equivalent single letter option to emulate if flag is null.
Throws:
java.lang.IllegalArgumentException - If the has_arg param is not one of NO_ARGUMENT, REQUIRED_ARGUMENT or OPTIONAL_ARGUMENT.
Method Detail

getName

public java.lang.String getName()
Returns the name of this LongOpt as a String
Returns:
The name of the long option

getDescription

public java.lang.String getDescription()
Returns the description of this LongOpt as a String
Returns:
The description of the long option

getPureDescription

public java.lang.String getPureDescription()
Return the pure, undecorated value of the description-attribute.

getDefault

public java.lang.String getDefault()

getAutoDefault

public boolean getAutoDefault()

setSecret

public void setSecret(boolean secret)

isSecret

public boolean isSecret()

getHasArg

public int getHasArg()
Returns the value set for the 'has_arg' field for this long option
Returns:
The value of 'has_arg'

getFlag

public java.lang.StringBuffer getFlag()
Returns the value of the 'flag' field for this long option
Returns:
The value of 'flag'

getVal

public int getVal()
Returns the value of the 'val' field for this long option
Returns:
The value of 'val'

validateArgument

public boolean validateArgument(java.lang.String value)
Validates the value of the option's argument
Parameters:
value - the value which shall be checked
Returns:
true if the argument is valid


This material is Copyrighted (C) 1999 by Tilo Christ. All Rights Reserved.