create container class for inserts
[jSite2.git] / src / net / pterodactylus / jsite / core / Insert.java
1 /*
2  * jSite2 - Insert.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.jsite.core;
21
22 /**
23  * Represents a currently running or past insert.
24  * 
25  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
26  */
27 public class Insert {
28
29         /** The project that was inserted. */
30         private final Project project;
31
32         /** The node the project was inserted to. */
33         private final Node node;
34
35         /** The start time of the insert. */
36         private final long startTime;
37
38         /** The end time of the insert. */
39         private long endTime;
40
41         /** Whether the insert was successful. */
42         private boolean success;
43
44         /**
45          * Creates a new insert.
46          * 
47          * @param project
48          *            The project that is inserted
49          * @param node
50          *            The node the project is inserted to
51          * @param startTime
52          *            The time the insert was started
53          */
54         public Insert(Project project, Node node, long startTime) {
55                 this.project = project;
56                 this.node = node;
57                 this.startTime = startTime;
58         }
59
60         /**
61          * Returns the project that is inserted.
62          * 
63          * @return The inserted project
64          */
65         public Project getProject() {
66                 return project;
67         }
68
69         /**
70          * Returns the node the project is inserted to.
71          * 
72          * @return The node the project is inserted to
73          */
74         public Node getNode() {
75                 return node;
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         /**
109          * Returns whether the insert was successful. When the project has not yet
110          * finished, i.e. {@link #getEndTime()} returns <code>-1</code>, the
111          * return value of this method is undefined.
112          * 
113          * @return <code>true</code> if the insert finished successfully,
114          *         <code>false</code> otherwise
115          */
116         public boolean isSuccess() {
117                 return success;
118         }
119
120         /**
121          * Sets whether the insert finished successfully.
122          * 
123          * @param success
124          *            <code>true</code> if the insert finished successfully,
125          *            <code>false</code> otherwise
126          */
127         public void setSuccess(boolean success) {
128                 this.success = success;
129         }
130
131 }