019dcdeffef90640645b86fa99093d7635acd594
[jSite2.git] / src / net / pterodactylus / jsite / core / Insert.java
1 /*
2  * jSite2 - Insert.java - Copyright © 2008 David Roden
3  * 
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  * 
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 package net.pterodactylus.jsite.core;
20
21 /**
22  * Represents a currently running or past insert.
23  * 
24  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
25  */
26 public class Insert extends Request {
27
28         /** The project that was inserted. */
29         private final Project project;
30
31         /** The start time of the insert. */
32         private final long startTime;
33
34         /** The end time of the insert. */
35         private long endTime;
36
37         /**
38          * Creates a new insert that starts now.
39          * 
40          * @param project
41          *            The project that is inserted
42          * @param node
43          *            The node the project is inserted to
44          * @param identifier
45          *            The identifier of the insert request
46          */
47         public Insert(Project project, Node node, String identifier) {
48                 this(project, node, identifier, System.currentTimeMillis());
49         }
50
51         /**
52          * Creates a new insert.
53          * 
54          * @param project
55          *            The project that is inserted
56          * @param node
57          *            The node the project is inserted to
58          * @param identifier
59          *            The identifier of the insert request
60          * @param startTime
61          *            The time the insert was started
62          */
63         public Insert(Project project, Node node, String identifier, long startTime) {
64                 super(node, identifier);
65                 this.project = project;
66                 this.startTime = startTime;
67         }
68
69         /**
70          * Returns the project that is inserted.
71          * 
72          * @return The inserted project
73          */
74         public Project getProject() {
75                 return project;
76         }
77
78         /**
79          * Returns the start time of the insert.
80          * 
81          * @return The start time of the insert
82          */
83         public long getStartTime() {
84                 return startTime;
85         }
86
87         /**
88          * Returns the end time of the insert. If the insert has not yet finished,
89          * <code>-1</code> is returned.
90          * 
91          * @return The end time of the insert, or <code>-1</code> if the insert is
92          *         still running
93          */
94         public long getEndTime() {
95                 return endTime;
96         }
97
98         /**
99          * Sets the end time of the insert.
100          * 
101          * @param endTime
102          *            The end time of the insert
103          */
104         public void setEndTime(long endTime) {
105                 this.endTime = endTime;
106         }
107
108 }