Package adams.core.option
Class ArrayConsumer
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.option.AbstractOptionConsumer<C,V>
-
- adams.core.option.AbstractRecursiveOptionConsumer<String[],String[]>
-
- adams.core.option.ArrayConsumer
-
- All Implemented Interfaces:
CleanUpHandler,LoggingSupporter,OptionConsumer<String[],String[]>,RecursiveOptionConsumer,SizeOfHandler,Serializable
public class ArrayConsumer extends AbstractRecursiveOptionConsumer<String[],String[]>
Parses a string array of options. The element in the string array must contain the classname of the object, the following ones are the actual options.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.option.AbstractRecursiveOptionConsumer
m_Nesting
-
Fields inherited from class adams.core.option.AbstractOptionConsumer
m_ClassnameCache, m_Errors, m_Input, m_Output, m_SkippedProperties, m_UsePropertyNames, m_Warnings
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description ArrayConsumer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String[]collectValues(AbstractOption option, String[] input)Collects all the arguments for given argument options.protected String[]convertToInput(String s)Converts the input string into the internal format.protected voiddoConsume(OptionManager manager, String[] input)Visits the options.protected StringextractClassname(String cmdline)Extracts the classname from the given commandline.StringglobalInfo()Returns a string describing the object.protected OptionHandlerinitOutput()Creates the empty option handler from the internal data structure and returns it.protected voidprocessOption(AbstractArgumentOption option, String[] values)Processes the specified argument option.protected voidprocessOption(BooleanOption option, String[] values)Processes the specified boolean option.protected voidprocessOption(ClassOption option, String[] values)Processes the specified class option.static voidsetOptions(OptionHandler handler, String[] options)Sets the options of the option handler.static voidsetOptions(OptionHandler handler, String[] options, boolean remaining)Sets the options of the option handler.-
Methods inherited from class adams.core.option.AbstractRecursiveOptionConsumer
cleanUp, generateLoggingString, getDebugIndentation, getDebugIndentation, getRecursionLevel, reset
-
Methods inherited from class adams.core.option.AbstractOptionConsumer
checkDeprecation, checkDeprecation, consume, consume, consume, determineCharset, forName, fromFile, fromFile, fromString, fromString, fromString, getErrors, getInput, getOptionIdentifier, getOutput, getSkippedProperties, getUsePropertyNames, getWarnings, getWriteMethod, hasErrors, hasWarnings, initialize, isQuiet, logError, logWarning, processOption, read, setInput, setLoggingLevel, setQuiet, setSkippedProperties
-
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, toString, wait, wait, wait
-
Methods inherited from interface adams.core.option.OptionConsumer
getLoggingLevel
-
-
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceOptionConsumer<String[],String[]>- Specified by:
globalInfoin classAbstractOptionConsumer<String[],String[]>- Returns:
- a description suitable for displaying in the gui
-
initOutput
protected OptionHandler initOutput()
Creates the empty option handler from the internal data structure and returns it. This option handler will then be "visited".- Specified by:
initOutputin classAbstractOptionConsumer<String[],String[]>- Returns:
- the generated option handler, null in case of an error
-
convertToInput
protected String[] convertToInput(String s)
Converts the input string into the internal format.- Specified by:
convertToInputin classAbstractOptionConsumer<String[],String[]>- Parameters:
s- the string to process- Returns:
- the internal format, null in case of an error
-
processOption
protected void processOption(BooleanOption option, String[] values) throws Exception
Processes the specified boolean option.- Specified by:
processOptionin classAbstractOptionConsumer<String[],String[]>- Parameters:
option- the boolean option to processvalues- ignored- Throws:
Exception- if something goes wrong
-
extractClassname
protected String extractClassname(String cmdline)
Extracts the classname from the given commandline.- Parameters:
cmdline- the commandline to process- Returns:
- the classname
-
processOption
protected void processOption(ClassOption option, String[] values) throws Exception
Processes the specified class option.- Specified by:
processOptionin classAbstractOptionConsumer<String[],String[]>- Parameters:
option- the class option to processvalues- the value(s) for the class option- Throws:
Exception- if something goes wrong
-
processOption
protected void processOption(AbstractArgumentOption option, String[] values) throws Exception
Processes the specified argument option.- Specified by:
processOptionin classAbstractOptionConsumer<String[],String[]>- Parameters:
option- the argument option to processvalues- the value(s) for the argument option- Throws:
Exception- if something goes wrong
-
collectValues
protected String[] collectValues(AbstractOption option, String[] input)
Collects all the arguments for given argument options.
NB: collection is destructive, i.e., the flags and values are removed from the array.- Parameters:
option- the option to gather the arguments forinput- the command-line array to process- Returns:
- the collected values
-
doConsume
protected void doConsume(OptionManager manager, String[] input)
Visits the options.- Specified by:
doConsumein classAbstractOptionConsumer<String[],String[]>- Parameters:
manager- the manager to visitinput- the input data to use
-
setOptions
public static void setOptions(OptionHandler handler, String[] options)
Sets the options of the option handler. Does check for remaining options.- Parameters:
handler- the object to set the options foroptions- the options to set
-
setOptions
public static void setOptions(OptionHandler handler, String[] options, boolean remaining)
Sets the options of the option handler.- Parameters:
handler- the object to set the options foroptions- the options to setremaining- whether to check for remaining options
-
-