04760e2b1ed417d4e6e519097466c99f562782d8
[jSite2.git] / src / net / pterodactylus / jsite / project / Project.java
1 /*
2  * jSite2 - Project.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.project;
21
22 import java.beans.PropertyChangeListener;
23
24 import net.pterodactylus.util.beans.AbstractBean;
25
26 /**
27  * Container for project information. A Project is capable of notifying
28  * {@link PropertyChangeListener}s if any of the contained properties change.
29  *
30  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
31  */
32 public class Project extends AbstractBean {
33
34         /** Name of the “name” property. */
35         public static final String PROPERTY_NAME = "name";
36
37         /** Name of the “description” property. */
38         public static final String PROPERTY_DESCRIPTION = "description";
39
40         /** Name of the “public key” property. */
41         public static final String PROPERTY_PUBLIC_KEY = "publicKey";
42
43         /** Name of the “private key” property. */
44         public static final String PROPERTY_PRIVATE_KEY = "privateKey";
45
46         /** Name of the “base path” property. */
47         public static final String PROPERTY_BASE_PATH = "basePath";
48
49         /** Internal ID. */
50         private String id;
51
52         /** The name of the project. */
53         private String name;
54
55         /** The description of the project. */
56         private String description;
57
58         /** The public key. */
59         private String publicKey;
60
61         /** The private key. */
62         private String privateKey;
63
64         /** The base path of the project. */
65         private String basePath;
66
67         /**
68          * Creates a new project.
69          */
70         public Project() {
71                 /* do nothing. */
72         }
73
74         /**
75          * Clones the given project.
76          *
77          * @param project
78          */
79         Project(Project project) {
80                 this.name = project.name;
81                 this.description = project.description;
82                 this.publicKey = project.publicKey;
83                 this.privateKey = project.privateKey;
84                 this.basePath = project.basePath;
85         }
86
87         /**
88          * Returns the internal ID.
89          *
90          * @return The internal ID
91          */
92         String getId() {
93                 return id;
94         }
95
96         /**
97          * Sets the internal ID.
98          *
99          * @param id
100          *            The internal ID
101          */
102         void setId(String id) {
103                 this.id = id;
104         }
105
106         /**
107          * Returns the name of the project.
108          *
109          * @return The name of the project
110          */
111         public String getName() {
112                 return name;
113         }
114
115         /**
116          * Sets the name of the project.
117          *
118          * @param name
119          *            The name of the project
120          */
121         public void setName(String name) {
122                 String oldName = this.name;
123                 this.name = name;
124                 fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
125         }
126
127         /**
128          * Returns the description of the project.
129          *
130          * @return The description of the project
131          */
132         public String getDescription() {
133                 return description;
134         }
135
136         /**
137          * Sets the description of the project
138          *
139          * @param description
140          *            The description of the project
141          */
142         public void setDescription(String description) {
143                 String oldDescription = this.description;
144                 this.description = description;
145                 fireIfPropertyChanged(PROPERTY_DESCRIPTION, oldDescription, description);
146         }
147
148         /**
149          * Returns the public key of the project.
150          *
151          * @return The public key of the project
152          */
153         public String getPublicKey() {
154                 return publicKey;
155         }
156
157         /**
158          * Sets the public key of the project.
159          *
160          * @param publicKey
161          *            The public key of the project
162          */
163         void setPublicKey(String publicKey) {
164                 String oldPublicKey = this.publicKey;
165                 this.publicKey = publicKey;
166                 fireIfPropertyChanged(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
167         }
168
169         /**
170          * Returns the private key of the project.
171          *
172          * @return The private key of the project
173          */
174         public String getPrivateKey() {
175                 return privateKey;
176         }
177
178         /**
179          * Sets the private key of the project.
180          *
181          * @param privateKey
182          *            The private key of the project
183          */
184         void setPrivateKey(String privateKey) {
185                 String oldPrivateKey = this.privateKey;
186                 this.privateKey = privateKey;
187                 fireIfPropertyChanged(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
188         }
189
190         /**
191          * Returns the base path of the project.
192          *
193          * @return The base path of the project
194          */
195         public String getBasePath() {
196                 return basePath;
197         }
198
199         /**
200          * Sets the base path of the project.
201          *
202          * @param basePath
203          *            The base path of the project
204          */
205         public void setBasePath(String basePath) {
206                 String oldBasePath = this.basePath;
207                 this.basePath = basePath;
208                 fireIfPropertyChanged(PROPERTY_BASE_PATH, oldBasePath, basePath);
209         }
210
211 }