org.apache.commons.cli2.util
Class HelpFormatter

java.lang.Object
  extended by org.apache.commons.cli2.util.HelpFormatter

public class HelpFormatter
extends java.lang.Object

Presents on screen help based on the application's Options


Field Summary
private  java.util.Comparator comparator
           
static java.util.Set DEFAULT_DISPLAY_USAGE_SETTINGS
          The default DisplaySettings used to select the help lines in the main body of help
static java.util.Set DEFAULT_FULL_USAGE_SETTINGS
          The default DisplaySettings used to select the elements to display in the displayed line of full usage information.
static int DEFAULT_FULL_WIDTH
          The default screen width
static java.lang.String DEFAULT_GUTTER_CENTER
          The default screen furniture right of screen
static java.lang.String DEFAULT_GUTTER_LEFT
          The default screen furniture left of screen
static java.lang.String DEFAULT_GUTTER_RIGHT
          The default screen furniture between columns
static java.util.Set DEFAULT_LINE_USAGE_SETTINGS
          The default DisplaySettings used to select the elements of usage per help line in the main body of help
private  java.util.Set displaySettings
           
private  java.lang.String divider
           
private  OptionException exception
           
private  java.lang.String footer
           
private  java.util.Set fullUsageSettings
           
private  Group group
           
private  java.lang.String gutterCenter
           
private  java.lang.String gutterLeft
           
private  java.lang.String gutterRight
           
private  java.lang.String header
           
private  java.util.Set lineUsageSettings
           
private  java.io.PrintWriter out
           
private  int pageWidth
           
private  java.lang.String shellCommand
           
 
Constructor Summary
HelpFormatter()
          Creates a new HelpFormatter using the defaults
HelpFormatter(java.lang.String gutterLeft, java.lang.String gutterCenter, java.lang.String gutterRight, int fullWidth)
          Creates a new HelpFormatter using the specified parameters
 
Method Summary
 java.util.Comparator getComparator()
           
 java.util.Set getDisplaySettings()
           
 java.lang.String getDivider()
           
 OptionException getException()
           
 java.lang.String getFooter()
           
 java.util.Set getFullUsageSettings()
           
 Group getGroup()
           
 java.lang.String getGutterCenter()
           
 java.lang.String getGutterLeft()
           
 java.lang.String getGutterRight()
           
 java.lang.String getHeader()
           
 java.util.Set getLineUsageSettings()
           
 int getPageWidth()
           
 java.io.PrintWriter getPrintWriter()
           
 java.lang.String getShellCommand()
           
protected static void pad(java.lang.String text, int width, java.io.PrintWriter writer)
           
 void print()
          Prints the Option help.
 void printDivider()
          Prints the divider text
 void printException()
          Prints any error message.
 void printFooter()
          Prints a footer string if necessary
 void printGutterLeft()
          Prints the left gutter string
 void printGutterRight()
          Prints the right gutter string
 void printHeader()
          Prints a header string if necessary
 void printHelp()
          Prints detailed help per option.
 void printUsage()
          Prints a single line of usage information (wrapping if necessary)
 void printWrapped(java.lang.String text)
          Prints a string wrapped if necessary
 void setComparator(java.util.Comparator comparator)
          The Comparator to use when sorting Options
 void setDisplaySettings(java.util.Set displaySettings)
          The DisplaySettings used to select the help lines in the main body of help
 void setDivider(java.lang.String divider)
          Sets the string to use as a divider between sections of help
 void setException(OptionException exception)
          Sets the exception to document
 void setFooter(java.lang.String footer)
          Sets the footer text of the help screen
 void setFullUsageSettings(java.util.Set fullUsageSettings)
          The DisplaySettings used to select the elements to display in the displayed line of full usage information.
 void setGroup(Group group)
          Sets the Group of Options to document
 void setHeader(java.lang.String header)
          Sets the footer text of the help screen
 void setLineUsageSettings(java.util.Set lineUsageSettings)
          Sets the DisplaySettings used to select elements in the per helpline usage strings.
 void setPrintWriter(java.io.PrintWriter out)
           
 void setShellCommand(java.lang.String shellCommand)
          Sets the command string used to invoke the application
protected static java.util.List wrap(java.lang.String text, int width)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FULL_WIDTH

public static final int DEFAULT_FULL_WIDTH
The default screen width

See Also:
Constant Field Values

DEFAULT_GUTTER_LEFT

public static final java.lang.String DEFAULT_GUTTER_LEFT
The default screen furniture left of screen

See Also:
Constant Field Values

DEFAULT_GUTTER_CENTER

public static final java.lang.String DEFAULT_GUTTER_CENTER
The default screen furniture right of screen

See Also:
Constant Field Values

DEFAULT_GUTTER_RIGHT

public static final java.lang.String DEFAULT_GUTTER_RIGHT
The default screen furniture between columns

See Also:
Constant Field Values

DEFAULT_FULL_USAGE_SETTINGS

public static final java.util.Set DEFAULT_FULL_USAGE_SETTINGS
The default DisplaySettings used to select the elements to display in the displayed line of full usage information.

See Also:
DisplaySetting

DEFAULT_LINE_USAGE_SETTINGS

public static final java.util.Set DEFAULT_LINE_USAGE_SETTINGS
The default DisplaySettings used to select the elements of usage per help line in the main body of help

See Also:
DisplaySetting

DEFAULT_DISPLAY_USAGE_SETTINGS

public static final java.util.Set DEFAULT_DISPLAY_USAGE_SETTINGS
The default DisplaySettings used to select the help lines in the main body of help


fullUsageSettings

private java.util.Set fullUsageSettings

lineUsageSettings

private java.util.Set lineUsageSettings

displaySettings

private java.util.Set displaySettings

exception

private OptionException exception

group

private Group group

comparator

private java.util.Comparator comparator

divider

private java.lang.String divider

header

private java.lang.String header

footer

private java.lang.String footer

shellCommand

private java.lang.String shellCommand

out

private java.io.PrintWriter out

gutterLeft

private final java.lang.String gutterLeft

gutterCenter

private final java.lang.String gutterCenter

gutterRight

private final java.lang.String gutterRight

pageWidth

private final int pageWidth
Constructor Detail

HelpFormatter

public HelpFormatter()
Creates a new HelpFormatter using the defaults


HelpFormatter

public HelpFormatter(java.lang.String gutterLeft,
                     java.lang.String gutterCenter,
                     java.lang.String gutterRight,
                     int fullWidth)
Creates a new HelpFormatter using the specified parameters

Parameters:
gutterLeft - the string marking left of screen
gutterCenter - the string marking center of screen
gutterRight - the string marking right of screen
fullWidth - the width of the screen
Method Detail

print

public void print()
Prints the Option help.


printException

public void printException()
Prints any error message.


printHelp

public void printHelp()
Prints detailed help per option.


printUsage

public void printUsage()
Prints a single line of usage information (wrapping if necessary)


printHeader

public void printHeader()
Prints a header string if necessary


printFooter

public void printFooter()
Prints a footer string if necessary


printWrapped

public void printWrapped(java.lang.String text)
Prints a string wrapped if necessary

Parameters:
text - the string to wrap

printGutterLeft

public void printGutterLeft()
Prints the left gutter string


printGutterRight

public void printGutterRight()
Prints the right gutter string


printDivider

public void printDivider()
Prints the divider text


pad

protected static void pad(java.lang.String text,
                          int width,
                          java.io.PrintWriter writer)

wrap

protected static java.util.List wrap(java.lang.String text,
                                     int width)

setComparator

public void setComparator(java.util.Comparator comparator)
The Comparator to use when sorting Options

Parameters:
comparator - Comparator to use when sorting Options

setDisplaySettings

public void setDisplaySettings(java.util.Set displaySettings)
The DisplaySettings used to select the help lines in the main body of help

Parameters:
displaySettings - the settings to use
See Also:
DisplaySetting

setDivider

public void setDivider(java.lang.String divider)
Sets the string to use as a divider between sections of help

Parameters:
divider - the dividing string

setException

public void setException(OptionException exception)
Sets the exception to document

Parameters:
exception - the exception that occured

setFooter

public void setFooter(java.lang.String footer)
Sets the footer text of the help screen

Parameters:
footer - the footer text

setFullUsageSettings

public void setFullUsageSettings(java.util.Set fullUsageSettings)
The DisplaySettings used to select the elements to display in the displayed line of full usage information.

Parameters:
fullUsageSettings -
See Also:
DisplaySetting

setGroup

public void setGroup(Group group)
Sets the Group of Options to document

Parameters:
group - the options to document

setHeader

public void setHeader(java.lang.String header)
Sets the footer text of the help screen

Parameters:
header - the footer text

setLineUsageSettings

public void setLineUsageSettings(java.util.Set lineUsageSettings)
Sets the DisplaySettings used to select elements in the per helpline usage strings.

Parameters:
lineUsageSettings - the DisplaySettings to use
See Also:
DisplaySetting

setShellCommand

public void setShellCommand(java.lang.String shellCommand)
Sets the command string used to invoke the application

Parameters:
shellCommand - the invokation command

getComparator

public java.util.Comparator getComparator()
Returns:
the Comparator used to sort the Group

getDisplaySettings

public java.util.Set getDisplaySettings()
Returns:
the DisplaySettings used to select HelpLines

getDivider

public java.lang.String getDivider()
Returns:
the String used as a horizontal section divider

getException

public OptionException getException()
Returns:
the Exception being documented by this HelpFormatter

getFooter

public java.lang.String getFooter()
Returns:
the help screen footer text

getFullUsageSettings

public java.util.Set getFullUsageSettings()
Returns:
the DisplaySettings used in the full usage string

getGroup

public Group getGroup()
Returns:
the group documented by this HelpFormatter

getGutterCenter

public java.lang.String getGutterCenter()
Returns:
the String used as the central gutter

getGutterLeft

public java.lang.String getGutterLeft()
Returns:
the String used as the left gutter

getGutterRight

public java.lang.String getGutterRight()
Returns:
the String used as the right gutter

getHeader

public java.lang.String getHeader()
Returns:
the help screen header text

getLineUsageSettings

public java.util.Set getLineUsageSettings()
Returns:
the DisplaySettings used in the per help line usage strings

getPageWidth

public int getPageWidth()
Returns:
the width of the screen in characters

getShellCommand

public java.lang.String getShellCommand()
Returns:
the command used to execute the application

setPrintWriter

public void setPrintWriter(java.io.PrintWriter out)
Parameters:
out - the PrintWriter to write to

getPrintWriter

public java.io.PrintWriter getPrintWriter()
Returns:
the PrintWriter that will be written to