public class HelpFormatter extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_SYNTAX_PREFIX
the string to display at the beginning of the usage statement
|
| Constructor and Description |
|---|
HelpFormatter(PrintWriter pw) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
createPadding(int len)
Return a String of padding of length
len. |
protected int |
findWrapPos(String text,
int width,
int startPos)
Finds the next text wrap position after
startPos for the
text in text with the column width width. |
int |
getDescPadding() |
String |
getHeader()
Print the header.
|
int |
getLeftPadding() |
String |
getNewLine() |
String |
getSyntaxPrefix() |
int |
getWidth()
Returns the 'width'.
|
void |
printHelp(ApiCommands[] commands)
Print the help for
ApiCommands with the specified command
line syntax. |
void |
printHelp(int width,
String cmdLineSyntax,
String header,
ApiCommands[] commands,
int leftPad,
int descPad,
String footer)
Print the help for
ApiCommands[] with the specified command
line syntax. |
void |
printHelp(int width,
String cmdLineSyntax,
String header,
ApiCommands[] commands,
String footer)
Print the help for
ApiCommands[] with the specified command
line syntax. |
void |
printOptions(int width,
ApiCommands[] commands,
int leftPad,
int descPad)
Print the help for the specified Options to the specified writer, using
the specified width, left padding and description padding.
|
void |
printUsage(int width,
String cmdLineSyntax)
Print the cmdLineSyntax to the specified writer, using the specified
width.
|
void |
printWrapped(int width,
String text)
Print the specified text to the specified PrintWriter.
|
void |
printWrapped(PrintWriter pw,
int width,
int nextLineTabStop,
String text)
Print the specified text to the specified PrintWriter.
|
protected StringBuffer |
renderCommands(StringBuffer sb,
int width,
ApiCommands[] commands,
int leftPad,
int descPad)
Render the specified ApiCommands and return the rendered ApiCommand in a
StringBuffer.
|
protected StringBuffer |
renderWrappedText(StringBuffer sb,
int width,
int nextLineTabStop,
String text)
Render the specified text and return the rendered Options in a
StringBuffer.
|
protected String |
rtrim(String s)
Remove the trailing whitespace from the specified String.
|
void |
setDescPadding(int defaultDescPad) |
void |
setLeftPadding(int leftPad) |
void |
setNewLine(String defaultNewLine) |
void |
setSyntaxPrefix(String syntaxPrefix) |
void |
setWidth(int width) |
public static final String DEFAULT_SYNTAX_PREFIX
public HelpFormatter(PrintWriter pw)
public String getNewLine()
public void setNewLine(String defaultNewLine)
defaultNewLine - the defaultNewLine to setpublic String getSyntaxPrefix()
public void setSyntaxPrefix(String syntaxPrefix)
syntaxPrefix - the syntaxPrefix to setpublic int getLeftPadding()
public int getDescPadding()
public void setLeftPadding(int leftPad)
leftPad - the leftPad to setpublic void setDescPadding(int defaultDescPad)
defaultDescPad - the defaultDescPad to setpublic int getWidth()
public void setWidth(int width)
width - the defaultWidth to setpublic void printHelp(ApiCommands[] commands)
ApiCommands with the specified command
line syntax. This method prints help information to System.out.commands - ApiCommands to formatpublic void printHelp(int width,
String cmdLineSyntax,
String header,
ApiCommands[] commands,
String footer)
ApiCommands[] with the specified command
line syntax. This method prints help information to System.out.width - the number of characters to be displayed on each linecmdLineSyntax - the syntax for this applicationheader - the banner to display at the beginning of the helpcommands - commands the Options instancefooter - the banner to display at the end of the helppublic void printHelp(int width,
String cmdLineSyntax,
String header,
ApiCommands[] commands,
int leftPad,
int descPad,
String footer)
ApiCommands[] with the specified command
line syntax.width - the number of characters to be displayed on each linecmdLineSyntax - the syntax for this applicationheader - the banner to display at the beginning of the helpcommands - the Commands 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 helpIllegalStateException - if there is no room to print a linepublic void printUsage(int width,
String cmdLineSyntax)
width - The number of characters per line for the usage statement.cmdLineSyntax - The usage statement.public void printWrapped(PrintWriter pw, int width, int nextLineTabStop, String text)
width - 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 PrintWriterprotected StringBuffer renderWrappedText(StringBuffer sb, int width, int nextLineTabStop, String text)
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.protected int findWrapPos(String text, int width, int startPos)
startPos for the
text in text with the column width width. The
wrap point is the last position before startPos+width having a whitespace
character (space, \n, \r). If there is no whitespace character before
startPos+width, it will return startPos+width.text - The text being searched for the wrap positionwidth - width of the wrapped textstartPos - position from which to start the lookup whitespace characterprotected String rtrim(String s)
s - The String to remove the trailing padding from.protected String createPadding(int len)
len.len - The length of the String of padding to create.public void printWrapped(int width,
String text)
width - The number of characters to display per linetext - The text to be written to the PrintWriterpublic String getHeader()
public void printOptions(int width,
ApiCommands[] commands,
int leftPad,
int descPad)
width - The number of characters to display per linecommands - commandsleftPad - the number of characters of padding to be prefixed to each
linedescPad - the number of characters of padding to be prefixed to each
description lineprotected StringBuffer renderCommands(StringBuffer sb, int width, ApiCommands[] commands, int leftPad, int descPad)
sb - The StringBuffer to place the rendered ApiCommand into.width - The number of characters to display per linecommands - The command line ApiCommandsleftPad - the number of characters of padding to be prefixed to each
linedescPad - the number of characters of padding to be prefixed to each
description lineCopyright © 2016. All rights reserved.