Package adams.data.spectrum
Class SpectrumJsonUtils
- java.lang.Object
-
- adams.data.spectrum.SpectrumJsonUtils
-
public class SpectrumJsonUtils extends Object
For converting spectra to JSON and vice versa.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEY_AMPLITUDES
static String
KEY_ID
static String
KEY_METADATA
static String
KEY_REFERENCE
static String
KEY_REPORT
static String
KEY_WAVES
-
Constructor Summary
Constructors Constructor Description SpectrumJsonUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
example(boolean useRefAndMeta)
Returns an example spectrum in JSON.static Spectrum
fromJson(com.google.gson.JsonObject jobj)
Creates a spectrum from the JSON object (spectral + report).static com.google.gson.JsonObject
toJson(Spectrum spec)
Turns the spectrum into a json structure (spectral + report).static com.google.gson.JsonObject
toJson(Spectrum spec, adams.data.report.Field[] ref, adams.data.report.Field[] meta)
Turns the spectrum into a json structure (spectral + ref + meta).
-
-
-
Field Detail
-
KEY_ID
public static final String KEY_ID
- See Also:
- Constant Field Values
-
KEY_WAVES
public static final String KEY_WAVES
- See Also:
- Constant Field Values
-
KEY_AMPLITUDES
public static final String KEY_AMPLITUDES
- See Also:
- Constant Field Values
-
KEY_REPORT
public static final String KEY_REPORT
- See Also:
- Constant Field Values
-
KEY_REFERENCE
public static final String KEY_REFERENCE
- See Also:
- Constant Field Values
-
KEY_METADATA
public static final String KEY_METADATA
- See Also:
- Constant Field Values
-
-
Method Detail
-
example
public static String example(boolean useRefAndMeta)
Returns an example spectrum in JSON.- Parameters:
useRefAndMeta
- whether to output example for ref/meta-data or complete report- Returns:
- the example string
-
fromJson
public static Spectrum fromJson(com.google.gson.JsonObject jobj)
Creates a spectrum from the JSON object (spectral + report).- Parameters:
jobj
- the object to get the data from- Returns:
- the spectrum, null if failed to create or find data
-
toJson
public static com.google.gson.JsonObject toJson(Spectrum spec)
Turns the spectrum into a json structure (spectral + report).- Parameters:
spec
- the spectrum to convert- Returns:
- the json data structure
- See Also:
KEY_AMPLITUDES
,KEY_WAVES
,KEY_REPORT
-
toJson
public static com.google.gson.JsonObject toJson(Spectrum spec, adams.data.report.Field[] ref, adams.data.report.Field[] meta)
Turns the spectrum into a json structure (spectral + ref + meta).- Parameters:
spec
- the spectrum to convertref
- the reference values to outputmeta
- the meta-data values to output- Returns:
- the json data structure
- See Also:
KEY_AMPLITUDES
,KEY_WAVES
,KEY_REFERENCE
,KEY_METADATA
-
-