2 * XdccDownloader - Download.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.xdcc.data;
20 import java.io.OutputStream;
21 import java.net.InetAddress;
23 import net.pterodactylus.irc.DccReceiver;
26 * Information about an ongoing download.
28 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
30 public class Download {
32 /** The bot that is being downloaded from. */
33 private final Bot bot;
35 /** The pack that is being downloaded. */
36 private final Pack pack;
38 /** The name of the file being downloaded. */
39 private String filename;
41 /** The size of the file being downloaded. */
42 private long filesize;
44 /** The remote address. */
45 private InetAddress remoteAddress;
47 /** The output stream. */
48 private OutputStream outputStream;
50 /** The DCC receiver. */
51 private DccReceiver dccReceiver;
54 * Creates a new download.
57 * The bot offering the download
59 * The pack being downloaded
61 public Download(Bot bot, Pack pack) {
71 * Returns the bot offering the download.
73 * @return The bot offering the download
80 * The pack that is being downloaded.
82 * @return The pack being downloaded
89 * The full name of the file being written.
91 * @return The full name of the file
93 public String filename() {
98 * Returns the size of the file.
100 * @return The size of the file
102 public long filesize() {
107 * Returns the remote address to download from.
109 * @return The remote address to download from
111 public InetAddress remoteAddress() {
112 return remoteAddress;
116 * The output stream that writes to the file.
118 * @return The output stream
120 public OutputStream outputStream() {
125 * The DCC receiver that is downloading the file
127 * @return The DCC receiver
129 public DccReceiver dccReceiver() {
138 * Sets the full name of the file being downloaded.
141 * The full name of the file
142 * @return This download
144 public Download filename(String filename) {
145 this.filename = filename;
150 * Sets the size of the download.
153 * The size of the download
154 * @return This download
156 public Download filesize(long filesize) {
157 this.filesize = filesize;
162 * Sets the remote address of the download.
164 * @param remoteAddress
165 * The remote address of the download
166 * @return This download
168 public Download remoteAddress(InetAddress remoteAddress) {
169 this.remoteAddress = remoteAddress;
174 * Sets the output stream the download is being written to
176 * @param outputStream
178 * @return This download
180 public Download outputStream(OutputStream outputStream) {
181 this.outputStream = outputStream;
186 * Sets the DCC receiver that downloads the file.
190 * @return This download
192 public Download dccReceiver(DccReceiver dccReceiver) {
193 this.dccReceiver = dccReceiver;