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 String
ENUM_SEPARATOR
the separator for enums.protected StringBuilder
m_OutputBuffer
the buffer for assembling the help.protected UserMode
m_UserMode
the user mode to generate the help for.static int
MAX_WIDTH
the 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 void
addArgumentInfo(AbstractArgumentOption option, StringBuilder buffer)
Adds additional information about the argument, e.g., the class.protected void
addToolTip(AbstractOption option, StringBuilder buffer)
Breaks up the tool tip and adds it to the StringBuilder.String
getOutput()
Returns the output generated from the visit.UserMode
getUserMode()
Returns the user mode to generate the help for.String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the visitor.protected String
initOutput()
Initializes the output data structure.static void
main(String[] args)
Executes the producer from commandline.protected void
preProduce()
Hook-method before starting visiting options.protected void
preProduce(OptionManager manager, int index)
Hook method that gets called just before an option gets produced.StringBuilder
processOption(AbstractArgumentOption option)
Visits an argument option.StringBuilder
processOption(BooleanOption option)
Visits a boolean option.StringBuilder
processOption(ClassOption option)
Visits a class option.void
setUserMode(UserMode value)
Sets the user mode to generate the help for.String
toString()
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:
globalInfo
in interfaceOptionProducer<String,StringBuilder>
- Specified by:
globalInfo
in 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:
setUserMode
in interfaceUserModeSupporter
- Parameters:
value
- the user mode
-
getUserMode
public UserMode getUserMode()
Returns the user mode to generate the help for.- Specified by:
getUserMode
in interfaceUserModeSupporter
- Returns:
- the user mode
-
initOutput
protected String initOutput()
Initializes the output data structure.- Specified by:
initOutput
in classAbstractOptionProducer<String,StringBuilder>
- Returns:
- the created data structure
-
initialize
protected void initialize()
Initializes the visitor.- Overrides:
initialize
in classAbstractOptionProducer<String,StringBuilder>
-
getOutput
public String getOutput()
Returns the output generated from the visit.- Specified by:
getOutput
in interfaceOptionProducer<String,StringBuilder>
- Overrides:
getOutput
in 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:
processOption
in interfaceOptionProducer<String,StringBuilder>
- Specified by:
processOption
in 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:
processOption
in interfaceOptionProducer<String,StringBuilder>
- Specified by:
processOption
in 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:
processOption
in interfaceOptionProducer<String,StringBuilder>
- Specified by:
processOption
in 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:
preProduce
in 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:
preProduce
in classAbstractOptionProducer<String,StringBuilder>
- See Also:
AbstractOptionProducer.initOutput()
-
toString
public String toString()
Returns the output generated from the visit.- Specified by:
toString
in interfaceOptionProducer<String,StringBuilder>
- Specified by:
toString
in 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
-
-