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