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";
51 /** Name of the “default file” property. */
52 public static final String PROPERTY_DEFAULT_FILE = "defaultFile";
57 /** The name of the project. */
60 /** The description of the project. */
61 private String description;
63 /** The public key. */
64 private String publicKey;
66 /** The private key. */
67 private String privateKey;
69 /** The base path of the project. */
70 private String basePath;
72 /** The default file. */
73 private String defaultFile;
76 private final Map<String, Override> overrides = new HashMap<String, Override>();
79 * Creates a new project.
86 * Clones the given project.
90 Project(Project project) {
91 this.name = project.name;
92 this.description = project.description;
93 this.publicKey = project.publicKey;
94 this.privateKey = project.privateKey;
95 this.basePath = project.basePath;
99 * Returns the internal ID.
101 * @return The internal ID
108 * Sets the internal ID.
113 void setId(String id) {
118 * Returns the name of the project.
120 * @return The name of the project
122 public String getName() {
127 * Sets the name of the project.
130 * The name of the project
132 public void setName(String name) {
133 String oldName = this.name;
135 fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
139 * Returns the description of the project.
141 * @return The description of the project
143 public String getDescription() {
148 * Sets the description of the project
151 * The description of the project
153 public void setDescription(String description) {
154 String oldDescription = this.description;
155 this.description = description;
156 fireIfPropertyChanged(PROPERTY_DESCRIPTION, oldDescription, description);
160 * Returns the public key of the project.
162 * @return The public key of the project
164 public String getPublicKey() {
169 * Sets the public key of the project.
172 * The public key of the project
174 void setPublicKey(String publicKey) {
175 String oldPublicKey = this.publicKey;
176 this.publicKey = publicKey;
177 fireIfPropertyChanged(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
181 * Returns the private key of the project.
183 * @return The private key of the project
185 public String getPrivateKey() {
190 * Sets the private key of the project.
193 * The private key of the project
195 void setPrivateKey(String privateKey) {
196 String oldPrivateKey = this.privateKey;
197 this.privateKey = privateKey;
198 fireIfPropertyChanged(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
202 * Returns the base path of the project.
204 * @return The base path of the project
206 public String getBasePath() {
211 * Sets the base path of the project.
214 * The base path of the project
216 public void setBasePath(String basePath) {
217 String oldBasePath = this.basePath;
218 this.basePath = basePath;
219 fireIfPropertyChanged(PROPERTY_BASE_PATH, oldBasePath, basePath);
223 * Returns the default file.
225 * @return The default file
227 public String getDefaultFile() {
232 * Sets the default file.
237 public void setDefaultFile(String defaultFile) {
238 String oldDefaultFile = this.defaultFile;
239 this.defaultFile = defaultFile;
240 fireIfPropertyChanged(PROPERTY_DEFAULT_FILE, oldDefaultFile, defaultFile);
244 * Adds an override for the given file.
249 * The override for the file
251 public void addOverride(String filePath, Override override) {
252 overrides.put(filePath, override);
256 * Removes the override for the given file.
259 * The file path for which to remove the override
261 public void removeOverride(String filePath) {
262 overrides.remove(filePath);
266 * Returns the list of {@link Override}s.
268 * @return All overrides
270 public Map<String, Override> getOverrides() {