001/* 002 * Copyright 2018 Leibniz-Institut für Analytische Wissenschaften – ISAS – e.V.. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.isas.mztab2.io; 017 018import de.isas.mztab2.model.MzTab; 019import java.io.IOException; 020import java.io.OutputStreamWriter; 021import java.nio.file.Path; 022import java.util.Optional; 023 024/** 025 * Interface for mztab writer implementors. 026 * 027 * @author nilshoffmann 028 * @param <T> the return type of the write methods. 029 */ 030public interface MzTabWriter<T> { 031 032 /** 033 * <p> 034 * Write the mzTab object to the provided output stream writer.</p> 035 * 036 * This method does not close the output stream but will issue a 037 * <code>flush</code> on the provided output stream writer! 038 * 039 * @param writer a {@link java.io.OutputStreamWriter} object. 040 * @param mzTab a {@link de.isas.mztab2.model.MzTab} object. 041 * @return the optional payload. 042 * @throws java.io.IOException if any errors occur during writing. 043 */ 044 Optional<T> write(OutputStreamWriter writer, MzTab mzTab) throws IOException; 045 046 /** 047 * <p> 048 * Write the mzTab object to the provided path file.</p> 049 * 050 * 051 * @param path a {@link java.nio.file.Path} object. 052 * @param mzTab a {@link de.isas.mztab2.model.MzTab} object. 053 * @return the optional payload. 054 * @throws java.io.IOException if any errors occur during writing. 055 */ 056 Optional<T> write(Path path, MzTab mzTab) throws IOException; 057 058}