Package adams.core.option
Class JsonConsumer
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.option.AbstractOptionConsumer<C,V>
-
- adams.core.option.AbstractRecursiveOptionConsumer<net.minidev.json.JSONObject,Object>
-
- adams.core.option.JsonConsumer
-
- All Implemented Interfaces:
CleanUpHandler
,FileFormatHandler
,LoggingSupporter
,OptionConsumer<net.minidev.json.JSONObject,Object>
,RecursiveOptionConsumer
,SizeOfHandler
,Serializable
public class JsonConsumer extends AbstractRecursiveOptionConsumer<net.minidev.json.JSONObject,Object> implements FileFormatHandler
Recreates objects from a JSON representation.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_CLASS
the key for the class name.static String
KEY_OPTIONS
the key for the options.-
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 JsonConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object[]
collectValues(AbstractOption option, net.minidev.json.JSONObject input)
Collects all the arguments for given argument options.protected net.minidev.json.JSONObject
convertToInput(String s)
Converts the input string into the internal format.protected void
doConsume(OptionManager manager, net.minidev.json.JSONObject input)
Visits the options.String
getDefaultFormatExtension()
Returns the default file extension (without the dot).String
getFormatDescription()
Returns the description of the file format.String[]
getFormatExtensions()
Returns the file extensions (without the dot).String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the members.protected OptionHandler
initOutput()
Initializes the output data structure.protected void
processOption(AbstractArgumentOption option, Object values)
Processes the specified argument option.protected void
processOption(BooleanOption option, Object values)
Processes the specified boolean option.protected void
processOption(ClassOption option, Object values)
Processes the specified class option.-
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, 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
-
-
-
-
Field Detail
-
KEY_CLASS
public static final String KEY_CLASS
the key for the class name.- See Also:
- Constant Field Values
-
KEY_OPTIONS
public static final String KEY_OPTIONS
the key for the options.- See Also:
- Constant Field Values
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceOptionConsumer<net.minidev.json.JSONObject,Object>
- Specified by:
globalInfo
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
- Returns:
- a description suitable for displaying in the gui
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
-
initOutput
protected OptionHandler initOutput()
Initializes the output data structure.- Specified by:
initOutput
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
- Returns:
- the created data structure
-
processOption
protected void processOption(BooleanOption option, Object values) throws Exception
Processes the specified boolean option.- Specified by:
processOption
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
- Parameters:
option
- the boolean option to processvalues
- the value for the boolean option- Throws:
Exception
- if something goes wrong
-
processOption
protected void processOption(ClassOption option, Object values) throws Exception
Processes the specified class option.- Specified by:
processOption
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
- Parameters:
option
- the class option to processvalues
- the value for the class option- Throws:
Exception
- if something goes wrong
-
processOption
protected void processOption(AbstractArgumentOption option, Object values) throws Exception
Processes the specified argument option.- Specified by:
processOption
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
- Parameters:
option
- the argument option to processvalues
- the value for the argument option- Throws:
Exception
- if something goes wrong
-
collectValues
protected Object[] collectValues(AbstractOption option, net.minidev.json.JSONObject input)
Collects all the arguments for given argument options.- 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, net.minidev.json.JSONObject input)
Visits the options.- Specified by:
doConsume
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
- Parameters:
manager
- the manager to visitinput
- the input data to use
-
convertToInput
protected net.minidev.json.JSONObject convertToInput(String s)
Converts the input string into the internal format.- Specified by:
convertToInput
in classAbstractOptionConsumer<net.minidev.json.JSONObject,Object>
- Parameters:
s
- the string to process- Returns:
- the internal format, null in case of an error
-
getFormatDescription
public String getFormatDescription()
Returns the description of the file format.- Specified by:
getFormatDescription
in interfaceFileFormatHandler
- Returns:
- the description
-
getDefaultFormatExtension
public String getDefaultFormatExtension()
Returns the default file extension (without the dot).- Specified by:
getDefaultFormatExtension
in interfaceFileFormatHandler
- Returns:
- the default extension
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the file extensions (without the dot).- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Returns:
- the extensions
-
-