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.AbstractTextBasedSpectrumWriter
-
- 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.DataContainerWriter>,adams.core.SizeOfHandler,adams.data.io.output.DataContainerWriter<Spectrum>,adams.data.io.output.StreamableDataContainerWriter<Spectrum>,adams.data.io.output.StreamableTextBasedDataContainerWriter<Spectrum>,Serializable,Comparable
public class ASCSpectrumWriter extends AbstractTextBasedSpectrumWriter implements adams.core.management.OptionHandlingLocaleSupporter
Writer that stores spectra 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
- Author:
- dale (dale at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringm_AccessoryNameThe Accessory Name to put in ASC header.protected booleanm_Descendingwhether to output the sample data as well.protected Doublem_FirstXPointFirst X WaveNumber.protected Stringm_InstrumentNameThe instrument name to put in ASC header.protected Doublem_LastXPointLast X WaveNumber.protected Localem_Localethe locale to use.protected intm_NrDatapointsIf -1 then calculate Nr of Datapoints, otherwise as specified, and fail if the number differs.protected Stringm_ProductCodeEither the Field name with the product code in it, or the actual product code.protected Booleanm_ProductCodeFromFieldGet 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 StringaccessoryNameTipText()Returns the tip text for this property.protected voidcheckData(List<Spectrum> data)Writer can only write single spectra.StringdataPointsTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.StringdescendingTipText()Returns the tip text for this property.StringfirstXPointTipText()Returns the tip text for this property.protected StringgenASCString(Spectrum data)Generate the ASC String to output.StringgetAccessoryName()Get accessory name.intgetDataPoints()Get number of data points. -1 means use as many as in spectrum.booleangetDescending()Returns whether to output spectrum points by descending x-axis.DoublegetFirstXPoint()Get first X wavenumber.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.StringgetInstrumentName()Get instrument name.DoublegetLastXPoint()Get last X wavenumber.LocalegetLocale()Returns the locale in use.StringgetProductCode()Get Product Code.BooleangetProductCodeFromField()Get product code from instance attribute?StringglobalInfo()Returns a string describing the object.protected voidinitialize()Initializes the members.StringinstrumentNameTipText()Returns the tip text for this property.StringlastXPointTipText()Returns the tip text for this property.StringlocaleTipText()Returns the tip text for this property.StringproductCodeFromFieldTipText()Returns the tip text for this property.StringproductCodeTipText()Returns the tip text for this property.voidsetAccessoryName(String mAccessoryName)Set accessory name.voidsetDataPoints(int mNrDatapoints)Set number of data points. -1 means use as many as in spectrum.voidsetDescending(boolean value)Sets whether to output spectrum points by descending x-axis.voidsetFirstXPoint(Double mFirstXPoint)Set first X wavenumber.voidsetInstrumentName(String mInstrumentName)Set instrument name.voidsetLastXPoint(Double mLastXPoint)Set last X wavenumber.voidsetLocale(Locale value)Sets the locale to use.voidsetProductCode(String productCode)Set product code.voidsetProductCodeFromField(Boolean mGetProductCodeFromAttribute)Set product code from instance attribute?protected booleanwriteData(List<Spectrum> data, Writer writer)Performs the actual writing.-
Methods inherited from class adams.data.io.output.AbstractTextBasedSpectrumWriter
write, write, writeData
-
Methods inherited from class adams.data.io.output.AbstractSpectrumWriter
canWriteMultiple, getWriters, outputTipText
-
Methods inherited from class adams.data.io.output.AbstractDataContainerWriter
cleanUp, compareTo, destroy, equals, forCommandLine, forName, getAdditionalInformation, getDefaultFormatExtension, getOutput, isOutputFile, 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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface adams.data.io.output.DataContainerWriter
canWriteMultiple, getOutput, isOutputFile, outputTipText, setOutput, write, write
-
-
-
-
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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin 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:
setLocalein interfaceadams.core.management.LocaleSupporter- Parameters:
value- the locale
-
getLocale
public Locale getLocale()
Returns the locale in use.- Specified by:
getLocalein interfaceadams.core.management.LocaleSupporter- Returns:
- the locale
-
localeTipText
public String localeTipText()
Returns the tip text for this property.- Specified by:
localeTipTextin 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:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin 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:
getFormatDescriptionin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatDescriptionin 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:
getFormatExtensionsin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatExtensionsin classadams.data.io.output.AbstractDataContainerWriter<Spectrum>- Returns:
- the extension(s) (without the dot!)
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein 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:
checkDatain classadams.data.io.output.AbstractDataContainerWriter<Spectrum>- Parameters:
data- the data to write
-
writeData
protected boolean writeData(List<Spectrum> data, Writer writer)
Performs the actual writing.- Specified by:
writeDatain classAbstractTextBasedSpectrumWriter- Parameters:
data- the data to writewriter- the writer to write the spectra to- Returns:
- true if successfully written
-
-