Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.commons.cli.HelpFormatter
public class HelpFormatter
extends java.lang.Object
Nested Class Summary | |
private static class |
|
Field Summary | |
static String |
|
static int |
|
static int |
|
static String |
|
static String |
|
static String |
|
static int |
|
String |
|
int |
|
int |
|
String |
|
String |
|
String |
|
String |
|
int |
|
Method Summary | |
private static void |
|
private static void |
|
protected String |
|
protected int |
|
String |
|
int |
|
int |
|
String |
|
String |
|
String |
|
String |
|
int |
|
void | |
void | |
void | |
void | |
void | |
void | |
void | |
void | |
void |
|
void |
|
void |
|
void |
|
void |
|
protected StringBuffer |
|
protected StringBuffer |
|
protected String |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
public static final String DEFAULT_ARG_NAME
default name for an argument
public static final int DEFAULT_DESC_PAD
the number of characters of padding to be prefixed to each description line
- Field Value:
- 3
public static final int DEFAULT_LEFT_PAD
default padding to the left of each line
- Field Value:
- 1
public static final String DEFAULT_LONG_OPT_PREFIX
default prefix for long Option
public static final String DEFAULT_OPT_PREFIX
default prefix for shortOpts
public static final String DEFAULT_SYNTAX_PREFIX
the string to display at the begining of the usage statement
public static final int DEFAULT_WIDTH
default number of characters per line
- Field Value:
- 74
public String defaultArgName
Deprecated. Scope will be made private for next major version - use get/setArgName methods instead.
the name of the argument
public int defaultDescPad
Deprecated. Scope will be made private for next major version - use get/setDescPadding methods instead.
the number of characters of padding to be prefixed to each description line
public int defaultLeftPad
Deprecated. Scope will be made private for next major version - use get/setLeftPadding methods instead.
amount of padding to the left of each line
public String defaultLongOptPrefix
Deprecated. Scope will be made private for next major version - use get/setLongOptPrefix methods instead.
the long Opt prefix
public String defaultNewLine
Deprecated. Scope will be made private for next major version - use get/setNewLine methods instead.
the new line string
public String defaultOptPrefix
Deprecated. Scope will be made private for next major version - use get/setOptPrefix methods instead.
the shortOpt prefix
public String defaultSyntaxPrefix
Deprecated. Scope will be made private for next major version - use get/setSyntaxPrefix methods instead.
the string to display at the begining of the usage statement
public int defaultWidth
Deprecated. Scope will be made private for next major version - use get/setWidth methods instead.
number of characters per line
private static void appendOption(StringBuffer buff, Option option, boolean required)
Appends the usage clause for an Option to a StringBuffer.
- Parameters:
buff
- the StringBuffer to append tooption
- the Option to appendrequired
- whether the Option is required or not
private static void appendOptionGroup(StringBuffer buff, OptionGroup group)
Appends the usage clause for an OptionGroup to a StringBuffer. The clause is wrapped in square brackets if the group is required. The display of the options is handled by appendOption
- Parameters:
buff
- the StringBuffer to append togroup
- the group to append
protected String createPadding(int len)
Return a String of padding of lengthlen
.
- Parameters:
len
- The length of the String of padding to create.
- Returns:
- The String of padding
protected int findWrapPos(String text, int width, int startPos)
Finds the next text wrap position afterstartPos
for the text intext
with the column widthwidth
. The wrap point is the last postion before startPos+width having a whitespace character (space, \n, \r).
- Parameters:
text
- The text being searched for the wrap positionwidth
- width of the wrapped textstartPos
- position from which to start the lookup whitespace character
- Returns:
- postion on which the text must be wrapped or -1 if the wrap position is at the end of the text
public String getArgName()
Returns the 'argName'.
- Returns:
- the 'argName'
public int getDescPadding()
Returns the 'descPadding'.
- Returns:
- the 'descPadding'
public int getLeftPadding()
Returns the 'leftPadding'.
- Returns:
- the 'leftPadding'
public String getLongOptPrefix()
Returns the 'longOptPrefix'.
- Returns:
- the 'longOptPrefix'
public String getNewLine()
Returns the 'newLine'.
- Returns:
- the 'newLine'
public String getOptPrefix()
Returns the 'optPrefix'.
- Returns:
- the 'optPrefix'
public String getSyntaxPrefix()
Returns the 'syntaxPrefix'.
- Returns:
- the 'syntaxPrefix'
public int getWidth()
Returns the 'width'.
- Returns:
- the 'width'
public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header, Options options, int leftPad, int descPad, String footer)
Print the help foroptions
with the specified command line syntax.
- Parameters:
pw
- the writer to which the help will be writtenwidth
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instanceleftPad
- the number of characters of padding to be prefixed to each linedescPad
- the number of characters of padding to be prefixed to each description linefooter
- the banner to display at the end of the help
public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header, Options options, int leftPad, int descPad, String footer, boolean autoUsage)
Print the help foroptions
with the specified command line syntax.
- Parameters:
pw
- the writer to which the help will be writtenwidth
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instanceleftPad
- the number of characters of padding to be prefixed to each linedescPad
- the number of characters of padding to be prefixed to each description linefooter
- the banner to display at the end of the helpautoUsage
- whether to print an automatically generated usage statement
public void printHelp(String cmdLineSyntax, String header, Options options, String footer)
Print the help foroptions
with the specified command line syntax. This method prints help information to System.out.
- Parameters:
cmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instancefooter
- the banner to display at the end of the help
public void printHelp(String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
Print the help foroptions
with the specified command line syntax. This method prints help information to System.out.
- Parameters:
cmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instancefooter
- the banner to display at the end of the helpautoUsage
- whether to print an automatically generated usage statement
public void printHelp(String cmdLineSyntax, Options options)
Print the help foroptions
with the specified command line syntax. This method prints help information to System.out.
- Parameters:
cmdLineSyntax
- the syntax for this applicationoptions
- the Options instance
public void printHelp(String cmdLineSyntax, Options options, boolean autoUsage)
Print the help foroptions
with the specified command line syntax. This method prints help information to System.out.
- Parameters:
cmdLineSyntax
- the syntax for this applicationoptions
- the Options instanceautoUsage
- whether to print an automatically generated usage statement
public void printHelp(int width, String cmdLineSyntax, String header, Options options, String footer)
Print the help foroptions
with the specified command line syntax. This method prints help information to System.out.
- Parameters:
width
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instancefooter
- the banner to display at the end of the help
public void printHelp(int width, String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
Print the help foroptions
with the specified command line syntax. This method prints help information to System.out.
- Parameters:
width
- the number of characters to be displayed on each linecmdLineSyntax
- the syntax for this applicationheader
- the banner to display at the begining of the helpoptions
- the Options instancefooter
- the banner to display at the end of the helpautoUsage
- whether to print an automatically generated usage statement
public void printOptions(PrintWriter pw, int width, Options options, int leftPad, int descPad)
Print the help for the specified Options to the specified writer, using the specified width, left padding and description padding.
- Parameters:
pw
- The printWriter to write the help towidth
- The number of characters to display per lineoptions
- The command line OptionsleftPad
- the number of characters of padding to be prefixed to each linedescPad
- the number of characters of padding to be prefixed to each description line
public void printUsage(PrintWriter pw, int width, String cmdLineSyntax)
Print the cmdLineSyntax to the specified writer, using the specified width.
- Parameters:
pw
- The printWriter to write the help towidth
- The number of characters per line for the usage statement.cmdLineSyntax
- The usage statement.
public void printUsage(PrintWriter pw, int width, String app, Options options)
Prints the usage statement for the specified application.
- Parameters:
pw
- The PrintWriter to print the usage statementwidth
- The number of characters to display per lineapp
- The application nameoptions
- The command line Options
public void printWrapped(PrintWriter pw, int width, String text)
Print the specified text to the specified PrintWriter.
- Parameters:
pw
- The printWriter to write the help towidth
- The number of characters to display per linetext
- The text to be written to the PrintWriter
public void printWrapped(PrintWriter pw, int width, int nextLineTabStop, String text)
Print the specified text to the specified PrintWriter.
- Parameters:
pw
- The printWriter to write the help towidth
- The number of characters to display per linenextLineTabStop
- The position on the next line for the first tab.text
- The text to be written to the PrintWriter
protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad)
Render the specified Options and return the rendered Options in a StringBuffer.
- Parameters:
sb
- The StringBuffer to place the rendered Options into.width
- The number of characters to display per lineoptions
- The command line OptionsleftPad
- the number of characters of padding to be prefixed to each linedescPad
- the number of characters of padding to be prefixed to each description line
- Returns:
- the StringBuffer with the rendered Options contents.
protected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text)
Render the specified text and return the rendered Options in a StringBuffer.
- Parameters:
sb
- The StringBuffer to place the rendered text into.width
- The number of characters to display per linenextLineTabStop
- The position on the next line for the first tab.text
- The text to be rendered.
- Returns:
- the StringBuffer with the rendered Options contents.
protected String rtrim(String s)
Remove the trailing whitespace from the specified String.
- Parameters:
s
- The String to remove the trailing padding from.
- Returns:
- The String of without the trailing padding
public void setArgName(String name)
Sets the 'argName'.
- Parameters:
name
- the new value of 'argName'
public void setDescPadding(int padding)
Sets the 'descPadding'.
- Parameters:
padding
- the new value of 'descPadding'
public void setLeftPadding(int padding)
Sets the 'leftPadding'.
- Parameters:
padding
- the new value of 'leftPadding'
public void setLongOptPrefix(String prefix)
Sets the 'longOptPrefix'.
- Parameters:
prefix
- the new value of 'longOptPrefix'
public void setNewLine(String newline)
Sets the 'newLine'.
- Parameters:
newline
- the new value of 'newLine'
public void setOptPrefix(String prefix)
Sets the 'optPrefix'.
- Parameters:
prefix
- the new value of 'optPrefix'
public void setSyntaxPrefix(String prefix)
Sets the 'syntaxPrefix'.
- Parameters:
prefix
- the new value of 'syntaxPrefix'
public void setWidth(int width)
Sets the 'width'.
- Parameters:
width
- the new value of 'width'