001/* 002 * HA-JDBC: High-Availability JDBC 003 * Copyright (C) 2012 Paul Ferraro 004 * 005 * This program is free software: you can redistribute it and/or modify 006 * it under the terms of the GNU Lesser General Public License as published by 007 * the Free Software Foundation, either version 3 of the License, or 008 * (at your option) any later version. 009 * 010 * This program is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 * GNU Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License 016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 017 */ 018package net.sf.hajdbc.sql; 019 020import java.io.Closeable; 021import java.io.File; 022import java.io.InputStream; 023import java.io.Reader; 024import java.sql.SQLException; 025 026/** 027 * Provides temp file support for serializing data for streams. 028 * Any files created by this object are deleted when {@link #close()} is called. 029 * 030 * @author Paul Ferraro 031 * @version $Revision: 1612 $ 032 * @since 1.0 033 */ 034public interface FileSupport<E extends Throwable> extends Closeable 035{ 036 /** 037 * Create a file from the specified binary input stream. 038 * @param inputStream a binary stream of data 039 * @return a temporary file 040 * @throws SQLException if an IO error occurs 041 */ 042 File createFile(InputStream inputStream) throws E; 043 044 /** 045 * Create a file from the specified character input stream 046 * @param reader a character stream of data 047 * @return a temporary file 048 * @throws SQLException if an IO error occurs 049 */ 050 File createFile(Reader reader) throws E; 051 052 /** 053 * Returns a reader for the specified file. 054 * @param file a temp file 055 * @return a reader 056 * @throws SQLException if IO error occurs 057 */ 058 Reader getReader(File file) throws E; 059 060 /** 061 * Returns an input stream for the specified file. 062 * @param file a temp file 063 * @return an input stream 064 * @throws SQLException if IO error occurs 065 */ 066 InputStream getInputStream(File file) throws E; 067}