Class AbstractDataContainerWriter<T extends DataContainer>

    • Field Detail

      • m_OutputIsFile

        protected boolean m_OutputIsFile
        indicates whether the output has to be a file (= default) or directory.
    • Constructor Detail

      • AbstractDataContainerWriter

        public AbstractDataContainerWriter()
    • Method Detail

      • getFormatDescription

        public abstract String getFormatDescription()
        Returns a string describing the format (used in the file chooser).
        Specified by:
        getFormatDescription in interface FileFormatHandler
        Returns:
        a description suitable for displaying in the file chooser
      • getFormatExtensions

        public abstract String[] getFormatExtensions()
        Returns the extension(s) of the format.
        Specified by:
        getFormatExtensions in interface FileFormatHandler
        Returns:
        the extension(s) (without the dot!)
      • reset

        protected void reset()
        Resets the writer (but does not clear the input data!). Derived classes must call this method in set-methods of parameters to assure the invalidation of previously generated data.
        Overrides:
        reset in class AbstractOptionHandler
      • isOutputFile

        public boolean isOutputFile()
        Returns whether the output needs to be a file or directory.
        Returns:
        true if the output needs to be a file, a directory otherwise
      • setOutput

        public void setOutput​(PlaceholderFile value)
        Sets the file/directory to write to.
        Parameters:
        value - the file/directory to write to
      • getOutput

        public PlaceholderFile getOutput()
        The file/directory to write to.
        Returns:
        the file/directory to write to
      • outputTipText

        public String outputTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • canWriteMultiple

        public abstract boolean canWriteMultiple()
        Returns whether writing of multiple containers is supported.
        Returns:
        true if multiple containers are supported
      • write

        public boolean write​(T data)
        Performs checks and writes the data.
        Parameters:
        data - the data to write
        Returns:
        true if successfully written
        See Also:
        write(List)
      • write

        public boolean write​(List<T> data)
        Performs checks and writes the data.
        Parameters:
        data - the data to write
        Returns:
        true if successfully written
      • checkData

        protected void checkData​(List<T> data)
        The default implementation only checks whether the provided file is an actual file and whether it exists (if m_OutputIsFile is TRUE). Otherwise the directory has to exist.
        Parameters:
        data - the data to write
      • writeData

        protected abstract boolean writeData​(List<T> data)
        Performs the actual writing.
        Parameters:
        data - the data to write
        Returns:
        true if successfully written
      • cleanUp

        public void cleanUp()
        Can be used to free up memory. Default implementation just calls reset() and sets the spectrum to null. Derived classes can add additional code.
        Specified by:
        cleanUp in interface CleanUpHandler
        See Also:
        reset()
      • compareTo

        public int compareTo​(Object o)
        Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

        Only compares the commandlines of the two objects.
        Specified by:
        compareTo in interface Comparable<T extends DataContainer>
        Parameters:
        o - the object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
        Throws:
        ClassCastException - if the specified object's type prevents it from being compared to this object.
      • equals

        public boolean equals​(Object o)
        Returns whether the two objects are the same.

        Only compares the commandlines of the two objects.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to be compared
        Returns:
        true if the object is the same as this one
      • getWriters

        public static String[] getWriters()
        Returns a list with classnames of writers.
        Returns:
        the writer classnames
      • forName

        public static AbstractDataContainerWriter forName​(String classname,
                                                          String[] options)
        Instantiates the spectrum writer with the given options.
        Parameters:
        classname - the classname of the writer to instantiate
        options - the options for the writer
        Returns:
        the instantiated writer or null if an error occurred
      • forCommandLine

        public static AbstractDataContainerWriter forCommandLine​(String cmdline)
        Instantiates the spectrum writer from the given commandline (i.e., classname and optional options).
        Parameters:
        cmdline - the classname (and optional options) of the writer to instantiate
        Returns:
        the instantiated writer or null if an error occurred