1 /*
2 * dpkg - Debian Package library and the Debian Package Maven plugin
3 * (c) Copyright 2016 Gerrit Hohl
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program 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 this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 package net.sourceforge.javadpkg.io;
20
21 import java.io.Closeable;
22 import java.io.IOException;
23
24 /**
25 * <p>
26 * A swap can be used for storing data temporarily.
27 * </p>
28 * <p>
29 * A swap consists of a {@link DataTarget} which can be used to write the data
30 * and a {@link DataSource} to read it afterwards. When the swap is closed the
31 * stored data will be deleted.
32 * </p>
33 *
34 * @author Gerrit Hohl (gerrit-hohl@users.sourceforge.net)
35 * @version <b>1.0</b>, 29.04.2016 by Gerrit Hohl
36 */
37 public interface DataSwap extends Closeable {
38
39
40 /**
41 * <p>
42 * Returns the target.
43 * </p>
44 * <p>
45 * Subsequent calls will return the same target.
46 * </p>
47 *
48 * @return The target.
49 * @throws IllegalStateException
50 * If the {@link #getSource()} method has been already called.
51 * @throws IOException
52 * If an I/O error occurs while creating the target.
53 */
54 DataTarget getTarget() throws IOException;
55
56
57 /**
58 * <p>
59 * Returns the source.
60 * </p>
61 * <p>
62 * Subsequent calls will return the same source.
63 * </p>
64 *
65 * @return The source.
66 * @throws IllegalStateException
67 * If the {@link #getTarget()} method hasn't been called before.
68 * @throws IOException
69 * If an I/O error occurs while creating the source.
70 */
71 DataSource getSource() throws IOException;
72
73
74 }