name.kevinlocke.ultragetopt
Class POSIXGetoptErrorFormatter

java.lang.Object
  extended by name.kevinlocke.ultragetopt.POSIXGetoptErrorFormatter
All Implemented Interfaces:
GetoptErrorFormatter

public class POSIXGetoptErrorFormatter
extends java.lang.Object
implements GetoptErrorFormatter

Error formatter designed to mimic the output of getopt as described in POSIX (via the Single Unix Specification).

Author:
Kevin Locke <kwl7@cornell.edu>
See Also:
Description of the getopts utility in the Single Unix Specification

Constructor Summary
POSIXGetoptErrorFormatter(java.lang.String programname)
          Create a new instance of the formatter for POSIX-like getopt errors.
 
Method Summary
 java.lang.String ambiguousOption(java.lang.String option, java.lang.String leaders)
          Formats an error message to indicate that the given option could not be unambiguously interpreted.
 java.lang.String missingRequiredArgument(char option, java.lang.String leaders)
          Formats an error message to indicate that the given option requires an argument and that none was found.
 java.lang.String missingRequiredArgument(java.lang.String option, java.lang.String leaders)
          Formats an error message to indicate that the given option requires an argument and that none was found.
 java.lang.String noArgumentAllowed(char option, java.lang.String leaders)
          Formats an error message to indicate that the given option does not accept any arguments.
 java.lang.String noArgumentAllowed(java.lang.String option, java.lang.String leaders)
          Formats an error message to indicate that the given option does not accept any arguments.
 java.lang.String unrecognizedOption(char option, java.lang.String leaders)
          Formats an error message to indicate that the given option was not recognized.
 java.lang.String unrecognizedOption(java.lang.String option, java.lang.String leaders)
          Formats an error message to indicate that the given option was not recognized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

POSIXGetoptErrorFormatter

public POSIXGetoptErrorFormatter(java.lang.String programname)
Create a new instance of the formatter for POSIX-like getopt errors.

Parameters:
programname - The name of the program for printing to messages
Method Detail

ambiguousOption

public java.lang.String ambiguousOption(java.lang.String option,
                                        java.lang.String leaders)
Description copied from interface: GetoptErrorFormatter
Formats an error message to indicate that the given option could not be unambiguously interpreted.

Specified by:
ambiguousOption in interface GetoptErrorFormatter
Parameters:
option - The option which was ambiguous
leaders - The leader characters of the option (e.g. "--")
Returns:
A string suitable for printing to the user to indicate this error has occurred

missingRequiredArgument

public java.lang.String missingRequiredArgument(java.lang.String option,
                                                java.lang.String leaders)
Description copied from interface: GetoptErrorFormatter
Formats an error message to indicate that the given option requires an argument and that none was found.

Specified by:
missingRequiredArgument in interface GetoptErrorFormatter
Parameters:
option - The option which does is missing an argument
leaders - The leader characters of the option (e.g. "--")
Returns:
A string suitable for printing to the user to indicate this error has occurred

missingRequiredArgument

public java.lang.String missingRequiredArgument(char option,
                                                java.lang.String leaders)
Description copied from interface: GetoptErrorFormatter
Formats an error message to indicate that the given option requires an argument and that none was found.

Specified by:
missingRequiredArgument in interface GetoptErrorFormatter
Parameters:
option - The option which does is missing an argument
leaders - The leader characters of the option (e.g. "--")
Returns:
A string suitable for printing to the user to indicate this error has occurred

noArgumentAllowed

public java.lang.String noArgumentAllowed(java.lang.String option,
                                          java.lang.String leaders)
Description copied from interface: GetoptErrorFormatter
Formats an error message to indicate that the given option does not accept any arguments.

Specified by:
noArgumentAllowed in interface GetoptErrorFormatter
Parameters:
option - The option which does not take arguments
leaders - The leader characters of the option (e.g. "--")
Returns:
A string suitable for printing to the user to indicate this error has occurred

noArgumentAllowed

public java.lang.String noArgumentAllowed(char option,
                                          java.lang.String leaders)
Description copied from interface: GetoptErrorFormatter
Formats an error message to indicate that the given option does not accept any arguments.

Specified by:
noArgumentAllowed in interface GetoptErrorFormatter
Parameters:
option - The option which does not take arguments
leaders - The leader characters of the option (e.g. "--")
Returns:
A string suitable for printing to the user to indicate this error has occurred

unrecognizedOption

public java.lang.String unrecognizedOption(java.lang.String option,
                                           java.lang.String leaders)
Description copied from interface: GetoptErrorFormatter
Formats an error message to indicate that the given option was not recognized.

Specified by:
unrecognizedOption in interface GetoptErrorFormatter
Parameters:
option - The option which was not recognized
leaders - The leader characters of the option (e.g. "--")
Returns:
A string suitable for printing to the user to indicate this error has occurred

unrecognizedOption

public java.lang.String unrecognizedOption(char option,
                                           java.lang.String leaders)
Description copied from interface: GetoptErrorFormatter
Formats an error message to indicate that the given option was not recognized.

Specified by:
unrecognizedOption in interface GetoptErrorFormatter
Parameters:
option - The option which was not recognized
leaders - The leader characters of the option (e.g. "--")
Returns:
A string suitable for printing to the user to indicate this error has occurred