Package adams.data.io.output
Class ASCSpectrumWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractDataContainerWriter<Spectrum>
-
- adams.data.io.output.AbstractSpectrumWriter
-
- adams.data.io.output.ASCSpectrumWriter
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.CleanUpHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.io.FileFormatHandler
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.management.LocaleSupporter
,adams.core.management.OptionHandlingLocaleSupporter
,adams.core.option.OptionHandler
,adams.core.ShallowCopySupporter<adams.data.io.output.AbstractDataContainerWriter>
,adams.core.SizeOfHandler
,Serializable
,Comparable
public class ASCSpectrumWriter extends AbstractSpectrumWriter implements adams.core.management.OptionHandlingLocaleSupporter
Writer that stores spectrums in the BLGG ASC format.
Valid options are:
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-output <adams.core.io.PlaceholderFile> (property: output) The file to write the container to. default: ${TMP}/out.tmp
-instrumentName <java.lang.String> (property: instrumentName) Instrument Name to be used in ASC header. default: <not implemented>
-accessoryName <java.lang.String> (property: accessoryName) Accessory Name to be used in ASC header. default: ABB-BOMEM MB160D
-productCode <java.lang.String> (property: productCode) Either the attribute name with the product code in it, or the actual product code to be used. default: 01
-productCodeFromField (property: productCodeFromField) Regex to find sample id. e.g 'sample_id'
-dataPoints <int> (property: dataPoints) Number of data points. -1 means use as many as in spectrum default: -1
-firstXPoint <java.lang.Double> (property: firstXPoint) First wavenumber default: 3749.3428948242
-lastXPoint <java.lang.Double> (property: lastXPoint) Last wavenumber default: 9998.2477195313
- Version:
- $Revision: 2242 $
- Author:
- dale (dale at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_AccessoryName
The Accessory Name to put in ASC header.protected boolean
m_Descending
whether to output the sample data as well.protected Double
m_FirstXPoint
First X WaveNumber.protected String
m_InstrumentName
The instrument name to put in ASC header.protected Double
m_LastXPoint
Last X WaveNumber.protected Locale
m_Locale
the locale to use.protected int
m_NrDatapoints
If -1 then calculate Nr of Datapoints, otherwise as specified, and fail if the number differs.protected String
m_ProductCode
Either the Field name with the product code in it, or the actual product code.protected Boolean
m_ProductCodeFromField
Get the product code from the Field named ProductCode in the Report?
-
Constructor Summary
Constructors Constructor Description ASCSpectrumWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
accessoryNameTipText()
Returns the tip text for this property.protected void
checkData(List<Spectrum> data)
Writer can only write single spectra.String
dataPointsTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.String
descendingTipText()
Returns the tip text for this property.String
firstXPointTipText()
Returns the tip text for this property.protected String
genASCString(Spectrum data)
Generate the ASC String to output.String
getAccessoryName()
Get accessory name.int
getDataPoints()
Get number of data points. -1 means use as many as in spectrum.boolean
getDescending()
Returns whether to output spectrum points by descending x-axis.Double
getFirstXPoint()
Get first X wavenumber.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.String
getInstrumentName()
Get instrument name.Double
getLastXPoint()
Get last X wavenumber.Locale
getLocale()
Returns the locale in use.String
getProductCode()
Get Product Code.Boolean
getProductCodeFromField()
Get product code from instance attribute?String
globalInfo()
Returns a string describing the object.protected void
initialize()
Initializes the members.String
instrumentNameTipText()
Returns the tip text for this property.String
lastXPointTipText()
Returns the tip text for this property.String
localeTipText()
Returns the tip text for this property.String
productCodeFromFieldTipText()
Returns the tip text for this property.String
productCodeTipText()
Returns the tip text for this property.void
setAccessoryName(String mAccessoryName)
Set accessory name.void
setDataPoints(int mNrDatapoints)
Set number of data points. -1 means use as many as in spectrum.void
setDescending(boolean value)
Sets whether to output spectrum points by descending x-axis.void
setFirstXPoint(Double mFirstXPoint)
Set first X wavenumber.void
setInstrumentName(String mInstrumentName)
Set instrument name.void
setLastXPoint(Double mLastXPoint)
Set last X wavenumber.void
setLocale(Locale value)
Sets the locale to use.void
setProductCode(String productCode)
Set product code.void
setProductCodeFromField(Boolean mGetProductCodeFromAttribute)
Set product code from instance attribute?protected boolean
writeData(List<Spectrum> data)
Performs the actual writing.-
Methods inherited from class adams.data.io.output.AbstractSpectrumWriter
canWriteMultiple, getWriters
-
Methods inherited from class adams.data.io.output.AbstractDataContainerWriter
cleanUp, compareTo, destroy, equals, forCommandLine, forName, getAdditionalInformation, getDefaultFormatExtension, getOutput, isOutputFile, outputTipText, reset, setOutput, shallowCopy, shallowCopy, write, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_InstrumentName
protected String m_InstrumentName
The instrument name to put in ASC header.
-
m_AccessoryName
protected String m_AccessoryName
The Accessory Name to put in ASC header.
-
m_ProductCode
protected String m_ProductCode
Either the Field name with the product code in it, or the actual product code. Decided by m_GetProductCodeFromAttribute.
-
m_ProductCodeFromField
protected Boolean m_ProductCodeFromField
Get the product code from the Field named ProductCode in the Report? Otherwise use the ProductCode string directly.
-
m_NrDatapoints
protected int m_NrDatapoints
If -1 then calculate Nr of Datapoints, otherwise as specified, and fail if the number differs.
-
m_FirstXPoint
protected Double m_FirstXPoint
First X WaveNumber.
-
m_LastXPoint
protected Double m_LastXPoint
Last X WaveNumber.
-
m_Descending
protected boolean m_Descending
whether to output the sample data as well.
-
m_Locale
protected Locale m_Locale
the locale to use.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.data.io.output.AbstractDataContainerWriter<Spectrum>
-
getDataPoints
public int getDataPoints()
Get number of data points. -1 means use as many as in spectrum.- Returns:
- number of data points
-
setDataPoints
public void setDataPoints(int mNrDatapoints)
Set number of data points. -1 means use as many as in spectrum.- Parameters:
mNrDatapoints
- number of data points
-
dataPointsTipText
public String dataPointsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getFirstXPoint
public Double getFirstXPoint()
Get first X wavenumber.- Returns:
- first X wavenumber
-
setFirstXPoint
public void setFirstXPoint(Double mFirstXPoint)
Set first X wavenumber.- Parameters:
mFirstXPoint
- X wavenumber
-
firstXPointTipText
public String firstXPointTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getLastXPoint
public Double getLastXPoint()
Get last X wavenumber.- Returns:
- last X wavenumber
-
setLastXPoint
public void setLastXPoint(Double mLastXPoint)
Set last X wavenumber.- Parameters:
mLastXPoint
- X wavenumber
-
lastXPointTipText
public String lastXPointTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getProductCodeFromField
public Boolean getProductCodeFromField()
Get product code from instance attribute? Or use as string.- Returns:
- Get product code from instance attribute?
-
setProductCodeFromField
public void setProductCodeFromField(Boolean mGetProductCodeFromAttribute)
Set product code from instance attribute? Or use as string.- Parameters:
mGetProductCodeFromAttribute
- Set product code from instance attribute?
-
productCodeFromFieldTipText
public String productCodeFromFieldTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getProductCode
public String getProductCode()
Get Product Code.- Returns:
- product code
-
setProductCode
public void setProductCode(String productCode)
Set product code.- Parameters:
productCode
- product code.
-
productCodeTipText
public String productCodeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getAccessoryName
public String getAccessoryName()
Get accessory name.- Returns:
- accessory name.
-
setAccessoryName
public void setAccessoryName(String mAccessoryName)
Set accessory name.- Parameters:
mAccessoryName
- accessory name.
-
accessoryNameTipText
public String accessoryNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getInstrumentName
public String getInstrumentName()
Get instrument name.- Returns:
- instrument name
-
setInstrumentName
public void setInstrumentName(String mInstrumentName)
Set instrument name.- Parameters:
mInstrumentName
- instrument name
-
instrumentNameTipText
public String instrumentNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setDescending
public void setDescending(boolean value)
Sets whether to output spectrum points by descending x-axis.- Parameters:
value
- if true then the output descending x-axis
-
getDescending
public boolean getDescending()
Returns whether to output spectrum points by descending x-axis.- Returns:
- true if output descending x-axis
-
descendingTipText
public String descendingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLocale
public void setLocale(Locale value)
Sets the locale to use.- Specified by:
setLocale
in interfaceadams.core.management.LocaleSupporter
- Parameters:
value
- the locale
-
getLocale
public Locale getLocale()
Returns the locale in use.- Specified by:
getLocale
in interfaceadams.core.management.LocaleSupporter
- Returns:
- the locale
-
localeTipText
public String localeTipText()
Returns the tip text for this property.- Specified by:
localeTipText
in interfaceadams.core.management.OptionHandlingLocaleSupporter
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceadams.core.io.FileFormatHandler
- Specified by:
getFormatDescription
in classadams.data.io.output.AbstractDataContainerWriter<Spectrum>
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceadams.core.io.FileFormatHandler
- Specified by:
getFormatExtensions
in classadams.data.io.output.AbstractDataContainerWriter<Spectrum>
- Returns:
- the extension(s) (without the dot!)
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.core.option.AbstractOptionHandler
-
genASCString
protected String genASCString(Spectrum data)
Generate the ASC String to output.- Parameters:
data
- the data to write- Returns:
- ASC file as string.
-
checkData
protected void checkData(List<Spectrum> data)
Writer can only write single spectra.- Overrides:
checkData
in classadams.data.io.output.AbstractDataContainerWriter<Spectrum>
- Parameters:
data
- the data to write
-
-