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 booleanm_PrettyPrintingwhether to use pretty printing.static StringMESSAGE_CHARSETthe 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 voiddefineOptions()Adds options to the internal list of options.Stringformat(Properties header, byte[] payload)Turns the command properties and payload into a single string to send.booleangetPrettyPrinting()Returns whether pretty-printing is used or not.StringglobalInfo()Returns a string describing the object.RemoteCommandparse(String data, MessageCollection errors)Instantiates the command from the received data string.StringprettyPrintingTipText()Returns the tip text for this property.RemoteCommandread(File file, MessageCollection errors)Reads a remote command from a file.voidsetPrettyPrinting(boolean value)Sets whether to use pretty-printing or not.booleanwrite(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:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
setPrettyPrinting
public void setPrettyPrinting(boolean value)
Sets whether to use pretty-printing or not.- Specified by:
setPrettyPrintingin interfacePrettyPrintingSupporter- Parameters:
value- true if to use pretty-printing
-
getPrettyPrinting
public boolean getPrettyPrinting()
Returns whether pretty-printing is used or not.- Specified by:
getPrettyPrintingin interfacePrettyPrintingSupporter- Returns:
- true if to use pretty-printing
-
prettyPrintingTipText
public String prettyPrintingTipText()
Returns the tip text for this property.- Specified by:
prettyPrintingTipTextin 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:
parsein 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:
formatin 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:
readin 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:
writein interfaceRemoteCommandProcessor- Parameters:
cmd- the command to writefile- the file to write toerrors- for collecting errors- Returns:
- true if successful
-
-