Class 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 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.
    • Constructor Detail

      • ASCSpectrumWriter

        public ASCSpectrumWriter()
    • Method Detail

      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.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 interface adams.core.management.LocaleSupporter
        Parameters:
        value - the locale
      • getLocale

        public Locale getLocale()
        Returns the locale in use.
        Specified by:
        getLocale in interface adams.core.management.LocaleSupporter
        Returns:
        the locale
      • localeTipText

        public String localeTipText()
        Returns the tip text for this property.
        Specified by:
        localeTipText in interface adams.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 interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.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 interface adams.core.io.FileFormatHandler
        Specified by:
        getFormatDescription in class adams.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 interface adams.core.io.FileFormatHandler
        Specified by:
        getFormatExtensions in class adams.data.io.output.AbstractDataContainerWriter<Spectrum>
        Returns:
        the extension(s) (without the dot!)
      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class adams.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 class adams.data.io.output.AbstractDataContainerWriter<Spectrum>
        Parameters:
        data - the data to write
      • writeData

        protected boolean writeData​(List<Spectrum> data)
        Performs the actual writing.
        Specified by:
        writeData in class adams.data.io.output.AbstractDataContainerWriter<Spectrum>
        Parameters:
        data - the data to write
        Returns:
        true if successfully written