From bb74afd16d9d6c8ec2fdb17e70f9deebcefb00e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 11 Apr 2013 08:17:41 +0200 Subject: [PATCH] Add container for download data. --- .../java/net/pterodactylus/xdcc/data/Download.java | 148 +++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 src/main/java/net/pterodactylus/xdcc/data/Download.java diff --git a/src/main/java/net/pterodactylus/xdcc/data/Download.java b/src/main/java/net/pterodactylus/xdcc/data/Download.java new file mode 100644 index 0000000..2d95537 --- /dev/null +++ b/src/main/java/net/pterodactylus/xdcc/data/Download.java @@ -0,0 +1,148 @@ +/* + * XdccDownloader - Download.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.xdcc.data; + +import java.io.OutputStream; + +import net.pterodactylus.irc.DccReceiver; + +/** + * Information about an ongoing download. + * + * @author David ‘Bombe’ Roden + */ +public class Download { + + /** The bot that is being downloaded from. */ + private final Bot bot; + + /** The pack that is being downloaded. */ + private final Pack pack; + + /** The name of the file being downloaded. */ + private String filename; + + /** The output stream. */ + private OutputStream outputStream; + + /** The DCC receiver. */ + private DccReceiver dccReceiver; + + /** + * Creates a new download. + * + * @param bot + * The bot offering the download + * @param pack + * The pack being downloaded + */ + public Download(Bot bot, Pack pack) { + this.bot = bot; + this.pack = pack; + } + + // + // ACCESSORS + // + + /** + * Returns the bot offering the download. + * + * @return The bot offering the download + */ + public Bot bot() { + return bot; + } + + /** + * The pack that is being downloaded. + * + * @return The pack being downloaded + */ + public Pack pack() { + return pack; + } + + /** + * The full name of the file being written. + * + * @return The full name of the file + */ + public String filename() { + return filename; + } + + /** + * The output stream that writes to the file. + * + * @return The output stream + */ + public OutputStream outputStream() { + return outputStream; + } + + /** + * The DCC receiver that is downloading the file + * + * @return The DCC receiver + */ + public DccReceiver dccReceiver() { + return dccReceiver; + } + + // + // MUTATORS + // + + /** + * Sets the full name of the file being downloaded. + * + * @param filename + * The full name of the file + * @return This download + */ + public Download filename(String filename) { + this.filename = filename; + return this; + } + + /** + * Sets the output stream the download is being written to + * + * @param outputStream + * The output stream + * @return This download + */ + public Download outputStream(OutputStream outputStream) { + this.outputStream = outputStream; + return this; + } + + /** + * Sets the DCC receiver that downloads the file. + * + * @param dccReceiver + * The DCC receiver + * @return This download + */ + public Download dccReceiver(DccReceiver dccReceiver) { + this.dccReceiver = dccReceiver; + return this; + } + +} -- 2.7.4