Package adams.scripting.processor
Class JsonProcessor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.scripting.processor.AbstractRemoteCommandProcessor
-
- adams.scripting.processor.JsonProcessor
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,PrettyPrintingSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,RemoteCommandProcessor
,Serializable
public class JsonProcessor extends AbstractRemoteCommandProcessor implements PrettyPrintingSupporter
Processor for remote commands in JSON format.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_PrettyPrinting
whether to use pretty printing.static String
MESSAGE_CHARSET
the char set for the messages.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description JsonProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.String
format(Properties header, byte[] payload)
Turns the command properties and payload into a single string to send.boolean
getPrettyPrinting()
Returns whether pretty-printing is used or not.String
globalInfo()
Returns a string describing the object.RemoteCommand
parse(String data, MessageCollection errors)
Instantiates the command from the received data string.String
prettyPrintingTipText()
Returns the tip text for this property.RemoteCommand
read(File file, MessageCollection errors)
Reads a remote command from a file.void
setPrettyPrinting(boolean value)
Sets whether to use pretty-printing or not.boolean
write(RemoteCommand cmd, File file, MessageCollection errors)
Writes a remote command to a file.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
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.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
MESSAGE_CHARSET
public static final String MESSAGE_CHARSET
the char set for the messages.- See Also:
- Constant Field Values
-
m_PrettyPrinting
protected boolean m_PrettyPrinting
whether to use pretty printing.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setPrettyPrinting
public void setPrettyPrinting(boolean value)
Sets whether to use pretty-printing or not.- Specified by:
setPrettyPrinting
in interfacePrettyPrintingSupporter
- Parameters:
value
- true if to use pretty-printing
-
getPrettyPrinting
public boolean getPrettyPrinting()
Returns whether pretty-printing is used or not.- Specified by:
getPrettyPrinting
in interfacePrettyPrintingSupporter
- Returns:
- true if to use pretty-printing
-
prettyPrintingTipText
public String prettyPrintingTipText()
Returns the tip text for this property.- Specified by:
prettyPrintingTipText
in interfacePrettyPrintingSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
parse
public RemoteCommand parse(String data, MessageCollection errors)
Instantiates the command from the received data string.- Specified by:
parse
in interfaceRemoteCommandProcessor
- Parameters:
data
- the data string to parseerrors
- for collecting errors- Returns:
- the instantiated command, null if failed to parse
-
format
public String format(Properties header, byte[] payload)
Turns the command properties and payload into a single string to send.- Specified by:
format
in interfaceRemoteCommandProcessor
- Parameters:
header
- the header datapayload
- the payload- Returns:
- the assembled string
-
read
public RemoteCommand read(File file, MessageCollection errors)
Reads a remote command from a file.- Specified by:
read
in interfaceRemoteCommandProcessor
- Parameters:
file
- the file to readerrors
- for collecting errors- Returns:
- the remote command, null if failed to load
-
write
public boolean write(RemoteCommand cmd, File file, MessageCollection errors)
Writes a remote command to a file.- Specified by:
write
in interfaceRemoteCommandProcessor
- Parameters:
cmd
- the command to writefile
- the file to write toerrors
- for collecting errors- Returns:
- true if successful
-
-