Coverage Report - org.jtheque.core.utils.file.jt.JTFileWriter
 
Classes in this File Line Coverage Branch Coverage Complexity
JTFileWriter
0 %
0/12
N/A
1.4
 
 1  
 package org.jtheque.core.utils.file.jt;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.file.able.BasicDataSource;
 20  
 import org.jtheque.core.utils.file.jt.able.IJTFileWriter;
 21  
 import org.jtheque.utils.io.FileException;
 22  
 
 23  
 import java.io.BufferedOutputStream;
 24  
 import java.io.DataOutputStream;
 25  
 import java.io.File;
 26  
 import java.io.FileNotFoundException;
 27  
 import java.io.FileOutputStream;
 28  
 
 29  
 /**
 30  
  * A writer for JT File.
 31  
  *
 32  
  * @author Baptiste Wicht
 33  
  */
 34  0
 public abstract class JTFileWriter implements IJTFileWriter {
 35  
     @Override
 36  
     public final void writeFile(File file, BasicDataSource source) throws FileException {
 37  
         try {
 38  0
             writeFile(new FileOutputStream(file), source);
 39  0
         } catch (FileNotFoundException e) {
 40  0
             throw new FileException("File not found", e);
 41  0
         }
 42  0
     }
 43  
 
 44  
     @Override
 45  
     public final void writeFile(String path, BasicDataSource source) throws FileException {
 46  0
         writeFile(new File(path), source);
 47  0
     }
 48  
 
 49  
     @Override
 50  
     public final void writeFile(FileOutputStream stream, BasicDataSource source) throws FileException {
 51  0
         writeFile(new BufferedOutputStream(stream), source);
 52  0
     }
 53  
 
 54  
     @Override
 55  
     public final void writeFile(BufferedOutputStream stream, BasicDataSource source) throws FileException {
 56  0
         writeFile(new DataOutputStream(stream), source);
 57  0
     }
 58  
 
 59  
     /**
 60  
      * Write a JT file to a stream.
 61  
      *
 62  
      * @param stream The stream to write to.
 63  
      * @param source The datasource.
 64  
      * @throws FileException Throws when an error occurs during the writing process.
 65  
      */
 66  
     protected abstract void writeFile(DataOutputStream stream, BasicDataSource source) throws FileException;
 67  
 }