2 * jSite2 - Project.java -
3 * Copyright © 2008 David Roden
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.
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.
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.
20 package net.pterodactylus.jsite.project;
22 import java.beans.PropertyChangeListener;
23 import java.util.HashMap;
26 import net.pterodactylus.util.beans.AbstractBean;
29 * Container for project information. A Project is capable of notifying
30 * {@link PropertyChangeListener}s if any of the contained properties change.
32 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
34 public class Project extends AbstractBean {
36 /** Name of the “name” property. */
37 public static final String PROPERTY_NAME = "name";
39 /** Name of the “description” property. */
40 public static final String PROPERTY_DESCRIPTION = "description";
42 /** Name of the “public key” property. */
43 public static final String PROPERTY_PUBLIC_KEY = "publicKey";
45 /** Name of the “private key” property. */
46 public static final String PROPERTY_PRIVATE_KEY = "privateKey";
48 /** Name of the “base path” property. */
49 public static final String PROPERTY_BASE_PATH = "basePath";
54 /** The name of the project. */
57 /** The description of the project. */
58 private String description;
60 /** The public key. */
61 private String publicKey;
63 /** The private key. */
64 private String privateKey;
66 /** The base path of the project. */
67 private String basePath;
70 private final Map<String, Override> overrides = new HashMap<String, Override>();
73 * Creates a new project.
80 * Clones the given project.
84 Project(Project project) {
85 this.name = project.name;
86 this.description = project.description;
87 this.publicKey = project.publicKey;
88 this.privateKey = project.privateKey;
89 this.basePath = project.basePath;
93 * Returns the internal ID.
95 * @return The internal ID
102 * Sets the internal ID.
107 void setId(String id) {
112 * Returns the name of the project.
114 * @return The name of the project
116 public String getName() {
121 * Sets the name of the project.
124 * The name of the project
126 public void setName(String name) {
127 String oldName = this.name;
129 fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
133 * Returns the description of the project.
135 * @return The description of the project
137 public String getDescription() {
142 * Sets the description of the project
145 * The description of the project
147 public void setDescription(String description) {
148 String oldDescription = this.description;
149 this.description = description;
150 fireIfPropertyChanged(PROPERTY_DESCRIPTION, oldDescription, description);
154 * Returns the public key of the project.
156 * @return The public key of the project
158 public String getPublicKey() {
163 * Sets the public key of the project.
166 * The public key of the project
168 void setPublicKey(String publicKey) {
169 String oldPublicKey = this.publicKey;
170 this.publicKey = publicKey;
171 fireIfPropertyChanged(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
175 * Returns the private key of the project.
177 * @return The private key of the project
179 public String getPrivateKey() {
184 * Sets the private key of the project.
187 * The private key of the project
189 void setPrivateKey(String privateKey) {
190 String oldPrivateKey = this.privateKey;
191 this.privateKey = privateKey;
192 fireIfPropertyChanged(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
196 * Returns the base path of the project.
198 * @return The base path of the project
200 public String getBasePath() {
205 * Sets the base path of the project.
208 * The base path of the project
210 public void setBasePath(String basePath) {
211 String oldBasePath = this.basePath;
212 this.basePath = basePath;
213 fireIfPropertyChanged(PROPERTY_BASE_PATH, oldBasePath, basePath);
217 * Adds an override for the given file.
222 * The override for the file
224 public void addOverride(String filePath, Override override) {
225 overrides.put(filePath, override);
229 * Removes the override for the given file.
232 * The file path for which to remove the override
234 public void removeOverride(String filePath) {
235 overrides.remove(filePath);
239 * Returns the list of {@link Override}s.
241 * @return All overrides
243 public Map<String, Override> getOverrides() {