Package adams.core.option
Class BaseObjectCommandLineHandler
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.option.AbstractCommandLineHandler
-
- adams.core.option.BaseObjectCommandLineHandler
-
- All Implemented Interfaces:
LoggingSupporter
,SizeOfHandler
,Serializable
public class BaseObjectCommandLineHandler extends AbstractCommandLineHandler
For BaseObject derived classes (mainly for favorites management).- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.option.AbstractCommandLineHandler
FILENAME, KEY_HANDLERS, m_Cache, m_HandlerClasses
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description BaseObjectCommandLineHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
fromArray(String[] args, MessageCollection errors)
Generates an object from the commandline options.Object
fromCommandLine(String cmd, MessageCollection errors)
Generates an object from the specified commandline.String[]
getOptions(Object obj)
Returns the commandline options (without classname) of the specified object.boolean
handles(Class cls)
Checks whether the given class can be processed.String
joinOptions(String[] args)
Turns the option array back into a commandline.boolean
setOptions(Object obj, String[] args)
Sets the options of the specified object.String[]
splitOptions(String cmdline)
Splits the commandline into an array.String[]
toArray(Object obj)
Generates an options array from the specified object.String
toCommandLine(Object obj)
Generates a commandline from the specified object.String
toShortCommandLine(Object obj)
Generates a commandline from the specified object.-
Methods inherited from class adams.core.option.AbstractCommandLineHandler
fromArray, fromCommandLine, getHandler, getHandler, handles, initHandlers, initialize
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Method Detail
-
fromCommandLine
public Object fromCommandLine(String cmd, MessageCollection errors)
Generates an object from the specified commandline.- Specified by:
fromCommandLine
in classAbstractCommandLineHandler
- Parameters:
cmd
- the commandline to create the object fromerrors
- for recording errors- Returns:
- the created object, null in case of error
-
fromArray
public Object fromArray(String[] args, MessageCollection errors)
Generates an object from the commandline options.- Specified by:
fromArray
in classAbstractCommandLineHandler
- Parameters:
args
- the commandline options to create the object fromerrors
- for recording errors- Returns:
- the created object, null in case of error
-
toCommandLine
public String toCommandLine(Object obj)
Generates a commandline from the specified object.- Specified by:
toCommandLine
in classAbstractCommandLineHandler
- Parameters:
obj
- the object to create the commandline for- Returns:
- the generated commandline
-
toShortCommandLine
public String toShortCommandLine(Object obj)
Generates a commandline from the specified object. Uses a shortened format, e.g., removing the package from the class.- Specified by:
toShortCommandLine
in classAbstractCommandLineHandler
- Parameters:
obj
- the object to create the commandline for- Returns:
- the generated commandline
-
toArray
public String[] toArray(Object obj)
Generates an options array from the specified object.- Specified by:
toArray
in classAbstractCommandLineHandler
- Parameters:
obj
- the object to create the array for- Returns:
- the generated array
-
getOptions
public String[] getOptions(Object obj)
Returns the commandline options (without classname) of the specified object.- Specified by:
getOptions
in classAbstractCommandLineHandler
- Parameters:
obj
- the object to get the options from- Returns:
- the base object value
-
setOptions
public boolean setOptions(Object obj, String[] args)
Sets the options of the specified object.- Specified by:
setOptions
in classAbstractCommandLineHandler
- Parameters:
obj
- the object to set the options forargs
- the options- Returns:
- true if successfully set
-
splitOptions
public String[] splitOptions(String cmdline)
Splits the commandline into an array.- Specified by:
splitOptions
in classAbstractCommandLineHandler
- Parameters:
cmdline
- the commandline to split- Returns:
- the generated array of options
-
joinOptions
public String joinOptions(String[] args)
Turns the option array back into a commandline.- Specified by:
joinOptions
in classAbstractCommandLineHandler
- Parameters:
args
- the options to turn into a commandline- Returns:
- the generated commandline
-
handles
public boolean handles(Class cls)
Checks whether the given class can be processed.- Specified by:
handles
in classAbstractCommandLineHandler
- Parameters:
cls
- the class to inspect- Returns:
- true if the handler can process the class
-
-