Package de.isas.mztab2.io
Class MzTabValidatingWriter
- java.lang.Object
-
- de.isas.mztab2.io.MzTabValidatingWriter
-
- All Implemented Interfaces:
MzTabWriter<List<ValidationMessage>>
public class MzTabValidatingWriter extends Object implements MzTabWriter<List<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(Validator<MzTab> validator, boolean skipWriteOnValidationFailure)
Uses the provided validator and default writer configuration.MzTabValidatingWriter(Validator<MzTab> validator, MzTabWriterDefaults writerDefaults, boolean skipWriteOnValidationFailure)
Uses the provided validator and writerDefaults.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<ValidationMessage>
getValidationMessagesForLevel(Optional<List<ValidationMessage>> validationMessages, ValidationMessage.MessageTypeEnum level)
Returns all validation messages ONLY at the given level.Optional<List<ValidationMessage>>
write(OutputStreamWriter writer, MzTab mzTab)
Write the mzTab object to the provided output stream writer.Optional<List<ValidationMessage>>
write(Path path, MzTab mzTab)
Write the mzTab object to the provided path file.
-
-
-
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(Validator<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(Validator<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<ValidationMessage>> write(OutputStreamWriter writer, 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 aflush
on the provided output stream writer!- Specified by:
write
in interfaceMzTabWriter<List<ValidationMessage>>
- Parameters:
writer
- aOutputStreamWriter
object.mzTab
- aMzTab
object.- Returns:
- the optional payload.
- Throws:
IOException
- if any errors occur during writing.
-
write
public Optional<List<ValidationMessage>> write(Path path, MzTab mzTab) throws IOException
Description copied from interface:MzTabWriter
Write the mzTab object to the provided path file.
- Specified by:
write
in interfaceMzTabWriter<List<ValidationMessage>>
- Parameters:
path
- aPath
object.mzTab
- aMzTab
object.- Returns:
- the optional payload.
- Throws:
IOException
- if any errors occur during writing.
-
getValidationMessagesForLevel
public static List<ValidationMessage> getValidationMessagesForLevel(Optional<List<ValidationMessage>> validationMessages, 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.
-
-