Add container for download data.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 06:17:41 +0000 (08:17 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 11 Apr 2013 06:17:41 +0000 (08:17 +0200)
src/main/java/net/pterodactylus/xdcc/data/Download.java [new file with mode: 0644]

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 (file)
index 0000000..2d95537
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.xdcc.data;
+
+import java.io.OutputStream;
+
+import net.pterodactylus.irc.DccReceiver;
+
+/**
+ * Information about an ongoing download.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+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;
+       }
+
+}