Package adams.core.option
Class CommandlineHelpProducer
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.option.AbstractOptionProducer<String,StringBuilder>
-
- adams.core.option.CommandlineHelpProducer
-
- All Implemented Interfaces:
CleanUpHandler,LoggingSupporter,OptionProducer<String,StringBuilder>,UserModeSupporter,SizeOfHandler,Serializable
public class CommandlineHelpProducer extends AbstractOptionProducer<String,StringBuilder> implements UserModeSupporter
Generates the help for the command-line.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringENUM_SEPARATORthe separator for enums.protected StringBuilderm_OutputBufferthe buffer for assembling the help.protected UserModem_UserModethe user mode to generate the help for.static intMAX_WIDTHthe maximum width for the option text (80 - TAB = 72).-
Fields inherited from class adams.core.option.AbstractOptionProducer
m_Input, m_LastGenerated, m_Output, m_OutputVariableValues, m_SkippedProperties, m_UsePropertyNames
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description CommandlineHelpProducer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddArgumentInfo(AbstractArgumentOption option, StringBuilder buffer)Adds additional information about the argument, e.g., the class.protected voidaddToolTip(AbstractOption option, StringBuilder buffer)Breaks up the tool tip and adds it to the StringBuilder.StringgetOutput()Returns the output generated from the visit.UserModegetUserMode()Returns the user mode to generate the help for.StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the visitor.protected StringinitOutput()Initializes the output data structure.static voidmain(String[] args)Executes the producer from commandline.protected voidpreProduce()Hook-method before starting visiting options.protected voidpreProduce(OptionManager manager, int index)Hook method that gets called just before an option gets produced.StringBuilderprocessOption(AbstractArgumentOption option)Visits an argument option.StringBuilderprocessOption(BooleanOption option)Visits a boolean option.StringBuilderprocessOption(ClassOption option)Visits a class option.voidsetUserMode(UserMode value)Sets the user mode to generate the help for.StringtoString()Returns the output generated from the visit.-
Methods inherited from class adams.core.option.AbstractOptionProducer
checkInput, cleanUp, doProduce, doProduce, generateLoggingString, getCurrentValue, getInput, getOptionIdentifier, getOutputVariableValues, getSkippedProperties, getUsePropertyNames, isDefaultValue, loggingLevelTipText, outputVariableValuesTipText, postProduce, postProduce, produce, produce, reset, runProducer, setLoggingLevel, setOutputVariableValues, setSkippedProperties, toString, write
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.option.OptionProducer
getLoggingLevel
-
-
-
-
Field Detail
-
MAX_WIDTH
public static final int MAX_WIDTH
the maximum width for the option text (80 - TAB = 72).- See Also:
- Constant Field Values
-
ENUM_SEPARATOR
public static final String ENUM_SEPARATOR
the separator for enums.- See Also:
- Constant Field Values
-
m_OutputBuffer
protected StringBuilder m_OutputBuffer
the buffer for assembling the help.
-
m_UserMode
protected UserMode m_UserMode
the user mode to generate the help for.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceOptionProducer<String,StringBuilder>- Specified by:
globalInfoin classAbstractOptionProducer<String,StringBuilder>- Returns:
- a description suitable for displaying in the gui
-
setUserMode
public void setUserMode(UserMode value)
Sets the user mode to generate the help for.- Specified by:
setUserModein interfaceUserModeSupporter- Parameters:
value- the user mode
-
getUserMode
public UserMode getUserMode()
Returns the user mode to generate the help for.- Specified by:
getUserModein interfaceUserModeSupporter- Returns:
- the user mode
-
initOutput
protected String initOutput()
Initializes the output data structure.- Specified by:
initOutputin classAbstractOptionProducer<String,StringBuilder>- Returns:
- the created data structure
-
initialize
protected void initialize()
Initializes the visitor.- Overrides:
initializein classAbstractOptionProducer<String,StringBuilder>
-
getOutput
public String getOutput()
Returns the output generated from the visit.- Specified by:
getOutputin interfaceOptionProducer<String,StringBuilder>- Overrides:
getOutputin classAbstractOptionProducer<String,StringBuilder>- Returns:
- the output
- See Also:
AbstractOptionProducer.initOutput()
-
addToolTip
protected void addToolTip(AbstractOption option, StringBuilder buffer)
Breaks up the tool tip and adds it to the StringBuilder.- Parameters:
option- the current option to obtain the data frombuffer- the buffer to add the tool tip to
-
addArgumentInfo
protected void addArgumentInfo(AbstractArgumentOption option, StringBuilder buffer)
Adds additional information about the argument, e.g., the class.- Parameters:
option- the current option to obtain the data frombuffer- the buffer to add the information to
-
processOption
public StringBuilder processOption(BooleanOption option)
Visits a boolean option.- Specified by:
processOptionin interfaceOptionProducer<String,StringBuilder>- Specified by:
processOptionin classAbstractOptionProducer<String,StringBuilder>- Parameters:
option- the boolean option- Returns:
- the last internal data structure that was generated
-
processOption
public StringBuilder processOption(ClassOption option)
Visits a class option.- Specified by:
processOptionin interfaceOptionProducer<String,StringBuilder>- Specified by:
processOptionin classAbstractOptionProducer<String,StringBuilder>- Parameters:
option- the class option- Returns:
- the last internal data structure that was generated
-
processOption
public StringBuilder processOption(AbstractArgumentOption option)
Visits an argument option.- Specified by:
processOptionin interfaceOptionProducer<String,StringBuilder>- Specified by:
processOptionin classAbstractOptionProducer<String,StringBuilder>- Parameters:
option- the argument option- Returns:
- the last internal data structure that was generated
-
preProduce
protected void preProduce(OptionManager manager, int index)
Hook method that gets called just before an option gets produced.
Default implementation does nothing- Overrides:
preProducein classAbstractOptionProducer<String,StringBuilder>- Parameters:
manager- the option managerindex- the index of the option
-
preProduce
protected void preProduce()
Hook-method before starting visiting options. Adds header and global info to the output buffer.- Overrides:
preProducein classAbstractOptionProducer<String,StringBuilder>- See Also:
AbstractOptionProducer.initOutput()
-
toString
public String toString()
Returns the output generated from the visit.- Specified by:
toStringin interfaceOptionProducer<String,StringBuilder>- Specified by:
toStringin classAbstractOptionProducer<String,StringBuilder>- Returns:
- the output, null in case of an error
-
main
public static void main(String[] args)
Executes the producer from commandline.- Parameters:
args- the commandline arguments, use -help for help
-
-