Class MzTabValidatingWriter

  • All Implemented Interfaces:
    MzTabWriter<List<de.isas.mztab2.model.ValidationMessage>>

    public class MzTabValidatingWriter
    extends Object
    implements MzTabWriter<List<de.isas.mztab2.model.ValidationMessage>>

    MzTabValidatingWriter allows to write MzTab objects after validation with a custom or default validator. Use this if you want to make sure that your fail satisfies the structural and minimal reporting constraints of mzTab. Otherwise, use the MzTabNonValidatingWriter.

    To create a validating writer using the default checks also applied by the parser, call:

    MzTabWriter validatingWriter = new MzTabValidatingWriter.Default();

    Otherwise, to create a non-validating instance, call:

    MzTabWriter plainWriter = new MzTabNonValidatingWriter();
    Author:
    nilshoffmann
    See Also:
    MzTabValidatingWriter, MzTabValidator
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  MzTabValidatingWriter.WriteAndParseValidator
      A default validator implemenation that first writes and then parses the created temporary file, performing the parser checks.
    • Constructor Summary

      Constructors 
      Constructor Description
      MzTabValidatingWriter()
      Uses default structural validation based on writing and parsing the written file with the default parsing checks.
      MzTabValidatingWriter​(de.isas.lipidomics.mztab2.validation.Validator<de.isas.mztab2.model.MzTab> validator, boolean skipWriteOnValidationFailure)
      Uses the provided validator and default writer configuration.
      MzTabValidatingWriter​(de.isas.lipidomics.mztab2.validation.Validator<de.isas.mztab2.model.MzTab> validator, MzTabWriterDefaults writerDefaults, boolean skipWriteOnValidationFailure)
      Uses the provided validator and writerDefaults.
    • Constructor Detail

      • MzTabValidatingWriter

        public MzTabValidatingWriter()
        Uses default structural validation based on writing and parsing the written file with the default parsing checks. The output file will not be written, if any validation failures occur.
      • MzTabValidatingWriter

        public MzTabValidatingWriter​(de.isas.lipidomics.mztab2.validation.Validator<de.isas.mztab2.model.MzTab> validator,
                                     boolean skipWriteOnValidationFailure)
        Uses the provided validator and default writer configuration. The output file will not be written, if any validation failures occur.
        Parameters:
        validator - the validator instance.
        skipWriteOnValidationFailure - if true, skips writing of the file if validation fails.
      • MzTabValidatingWriter

        public MzTabValidatingWriter​(de.isas.lipidomics.mztab2.validation.Validator<de.isas.mztab2.model.MzTab> validator,
                                     MzTabWriterDefaults writerDefaults,
                                     boolean skipWriteOnValidationFailure)
        Uses the provided validator and writerDefaults.
        Parameters:
        validator - the validator instance.
        writerDefaults - the default writer settings.
        skipWriteOnValidationFailure - if true, skips writing of the file if validation fails.
    • Method Detail

      • write

        public Optional<List<de.isas.mztab2.model.ValidationMessage>> write​(OutputStreamWriter writer,
                                                                            de.isas.mztab2.model.MzTab mzTab)
                                                                     throws IOException
        Description copied from interface: MzTabWriter

        Write the mzTab object to the provided output stream writer.

        This method does not close the output stream but will issue a flush on the provided output stream writer!
        Specified by:
        write in interface MzTabWriter<List<de.isas.mztab2.model.ValidationMessage>>
        Parameters:
        writer - a OutputStreamWriter object.
        mzTab - a MzTab object.
        Returns:
        the optional payload.
        Throws:
        IOException - if any errors occur during writing.
      • write

        public Optional<List<de.isas.mztab2.model.ValidationMessage>> write​(Path path,
                                                                            de.isas.mztab2.model.MzTab mzTab)
                                                                     throws IOException
        Description copied from interface: MzTabWriter

        Write the mzTab object to the provided path file.

        Specified by:
        write in interface MzTabWriter<List<de.isas.mztab2.model.ValidationMessage>>
        Parameters:
        path - a Path object.
        mzTab - a MzTab object.
        Returns:
        the optional payload.
        Throws:
        IOException - if any errors occur during writing.
      • getValidationMessagesForLevel

        public static List<de.isas.mztab2.model.ValidationMessage> getValidationMessagesForLevel​(Optional<List<de.isas.mztab2.model.ValidationMessage>> validationMessages,
                                                                                                 de.isas.mztab2.model.ValidationMessage.MessageTypeEnum level)
        Returns all validation messages ONLY at the given level. E.g. if you provide Info, you will ONLY receive Info messages, even if Warn or Error messages have been produced!
        Parameters:
        validationMessages - the messages to apply the filter on.
        level - the message level.
        Returns:
        the list of validation messages matching the provided level.