Package adams.data.conversion
Class SpectrumToJson
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.conversion.AbstractConversion
-
- adams.data.conversion.SpectrumToJson
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler,adams.core.CleanUpHandler,adams.core.Destroyable,adams.core.GlobalInfoSupporter,adams.core.io.PrettyPrintingSupporter,adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.core.option.OptionHandler,adams.core.QuickInfoSupporter,adams.core.ShallowCopySupporter<adams.data.conversion.AbstractConversion>,adams.core.SizeOfHandler,adams.core.Stoppable,adams.data.conversion.Conversion,Serializable
public class SpectrumToJson extends adams.data.conversion.AbstractConversion implements adams.core.io.PrettyPrintingSupporterTurns a spectrum into a JSON string.
Output format:
- outputting the complete report:
{
"id": "someid",
"format": "NIR",
"waves": [1.0, 2.0],
"amplitudes": [1.1, 2.1],
"report": {
"Sample ID": "someid",
"GLV2": 1.123,
"valid": true
}
}
- outputting specific reference and meta-data values:
{
"id": "someid",
"format": "NIR",
"waves": [1.0, 2.0],
"amplitudes": [1.1, 2.1],
"reference": {
"GLV2": 1.123
},
"meta-data": {
"valid": true
}
}
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-use-reference-and-metadata <boolean> (property: useReferenceAndMetaData) If enabled, the only the specified reference and meta-data report values are output (in separate sections). default: false
-reference-value <adams.data.report.Field> [-reference-value ...] (property: referenceValues) The reference values to output. default:
-metadata-value <adams.data.report.Field> [-metadata-value ...] (property: metaDataValues) The meta-data values to output. default:
-pretty-printing <boolean> (property: prettyPrinting) If enabled, the output is printed in a 'pretty' format. default: false
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.data.report.Field[]m_MetaDataValuesthe meta-data values.protected booleanm_PrettyPrintingwhether to use pretty-printing.protected adams.data.report.Field[]m_ReferenceValuesthe reference values.protected booleanm_UseReferenceAndMetaDatawhether to output speficied reference and meta-data values.
-
Constructor Summary
Constructors Constructor Description SpectrumToJson()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Classaccepts()Returns the class that is accepted as input.voiddefineOptions()Adds options to the internal list of options.protected ObjectdoConvert()Performs the actual conversion.Classgenerates()Returns the class that is generated as output.adams.data.report.Field[]getMetaDataValues()Returns the meta-data values to output.booleangetPrettyPrinting()Returns whether pretty-printing is used or not.StringgetQuickInfo()Returns a quick info about the object, which can be displayed in the GUI.adams.data.report.Field[]getReferenceValues()Returns the reference values to output.booleangetUseReferenceAndMetaData()Returns whether only the specified reference and meta-data report values are output (in separate sections).StringglobalInfo()Returns a string describing the object.StringmetaDataValuesTipText()Returns the tip text for this property.StringprettyPrintingTipText()Returns the tip text for this property.StringreferenceValuesTipText()Returns the tip text for this property.voidsetMetaDataValues(adams.data.report.Field[] value)Sets the meta-data values to output.voidsetPrettyPrinting(boolean value)Sets whether to use pretty-printing or not.voidsetReferenceValues(adams.data.report.Field[] value)Sets the reference values to output.voidsetUseReferenceAndMetaData(boolean value)Sets whether only the specified reference and meta-data report values are output (in separate sections).StringuseReferenceAndMetaDataTipText()Returns the tip text for this property.-
Methods inherited from class adams.data.conversion.AbstractConversion
checkData, cleanUp, convert, getAdditionalInformation, getInput, getInput, getOutput, getOutput, getOwner, reset, setInput, setOwner, shallowCopy, shallowCopy, stopExecution
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_UseReferenceAndMetaData
protected boolean m_UseReferenceAndMetaData
whether to output speficied reference and meta-data values.
-
m_ReferenceValues
protected adams.data.report.Field[] m_ReferenceValues
the reference values.
-
m_MetaDataValues
protected adams.data.report.Field[] m_MetaDataValues
the meta-data 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 interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.core.option.AbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
setUseReferenceAndMetaData
public void setUseReferenceAndMetaData(boolean value)
Sets whether only the specified reference and meta-data report values are output (in separate sections).- Parameters:
value- true if to use pretty-printing
-
getUseReferenceAndMetaData
public boolean getUseReferenceAndMetaData()
Returns whether only the specified reference and meta-data report values are output (in separate sections).- Returns:
- true if to use pretty-printing
-
useReferenceAndMetaDataTipText
public String useReferenceAndMetaDataTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setReferenceValues
public void setReferenceValues(adams.data.report.Field[] value)
Sets the reference values to output.- Parameters:
value- the fields
-
getReferenceValues
public adams.data.report.Field[] getReferenceValues()
Returns the reference values to output.- Returns:
- the fields
-
referenceValuesTipText
public String referenceValuesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setMetaDataValues
public void setMetaDataValues(adams.data.report.Field[] value)
Sets the meta-data values to output.- Parameters:
value- the fields
-
getMetaDataValues
public adams.data.report.Field[] getMetaDataValues()
Returns the meta-data values to output.- Returns:
- the fields
-
metaDataValuesTipText
public String metaDataValuesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPrettyPrinting
public void setPrettyPrinting(boolean value)
Sets whether to use pretty-printing or not.- Specified by:
setPrettyPrintingin interfaceadams.core.io.PrettyPrintingSupporter- Parameters:
value- true if to use pretty-printing
-
getPrettyPrinting
public boolean getPrettyPrinting()
Returns whether pretty-printing is used or not.- Specified by:
getPrettyPrintingin interfaceadams.core.io.PrettyPrintingSupporter- Returns:
- true if to use pretty-printing
-
prettyPrintingTipText
public String prettyPrintingTipText()
Returns the tip text for this property.- Specified by:
prettyPrintingTipTextin interfaceadams.core.io.PrettyPrintingSupporter- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the object, which can be displayed in the GUI.- Specified by:
getQuickInfoin interfaceadams.core.QuickInfoSupporter- Overrides:
getQuickInfoin classadams.data.conversion.AbstractConversion- Returns:
- null if no info available, otherwise short string
-
accepts
public Class accepts()
Returns the class that is accepted as input.- Specified by:
acceptsin interfaceadams.data.conversion.Conversion- Specified by:
acceptsin classadams.data.conversion.AbstractConversion- Returns:
- the class
-
generates
public Class generates()
Returns the class that is generated as output.- Specified by:
generatesin interfaceadams.data.conversion.Conversion- Specified by:
generatesin classadams.data.conversion.AbstractConversion- Returns:
- the class
-
-