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;
24 import java.util.List;
27 import net.pterodactylus.util.beans.AbstractBean;
30 * Container for project information. A Project is capable of notifying
31 * {@link PropertyChangeListener}s if any of the contained properties change.
33 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
35 public class Project extends AbstractBean {
37 /** Name of the “name” property. */
38 public static final String PROPERTY_NAME = "name";
40 /** Name of the “description” property. */
41 public static final String PROPERTY_DESCRIPTION = "description";
43 /** Name of the “public key” property. */
44 public static final String PROPERTY_PUBLIC_KEY = "publicKey";
46 /** Name of the “private key” property. */
47 public static final String PROPERTY_PRIVATE_KEY = "privateKey";
49 /** Name of the “base path” property. */
50 public static final String PROPERTY_BASE_PATH = "basePath";
52 /** Name of the “default file” property. */
53 public static final String PROPERTY_DEFAULT_FILE = "defaultFile";
58 /** The name of the project. */
61 /** The description of the project. */
62 private String description;
64 /** The public key. */
65 private String publicKey;
67 /** The private key. */
68 private String privateKey;
70 /** The base path of the project. */
71 private String basePath;
73 /** The default file. */
74 private String defaultFile;
77 private final Map<String, Override> overrides = new HashMap<String, Override>();
80 * Creates a new project.
87 * Clones the given project.
91 Project(Project project) {
92 this.name = project.name;
93 this.description = project.description;
94 this.publicKey = project.publicKey;
95 this.privateKey = project.privateKey;
96 this.basePath = project.basePath;
100 * Returns the internal ID.
102 * @return The internal ID
109 * Sets the internal ID.
114 void setId(String id) {
119 * Returns the name of the project.
121 * @return The name of the project
123 public String getName() {
128 * Sets the name of the project.
131 * The name of the project
133 public void setName(String name) {
134 String oldName = this.name;
136 fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
140 * Returns the description of the project.
142 * @return The description of the project
144 public String getDescription() {
149 * Sets the description of the project
152 * The description of the project
154 public void setDescription(String description) {
155 String oldDescription = this.description;
156 this.description = description;
157 fireIfPropertyChanged(PROPERTY_DESCRIPTION, oldDescription, description);
161 * Returns the public key of the project.
163 * @return The public key of the project
165 public String getPublicKey() {
170 * Sets the public key of the project.
173 * The public key of the project
175 void setPublicKey(String publicKey) {
176 String oldPublicKey = this.publicKey;
177 this.publicKey = publicKey;
178 fireIfPropertyChanged(PROPERTY_PUBLIC_KEY, oldPublicKey, publicKey);
182 * Returns the private key of the project.
184 * @return The private key of the project
186 public String getPrivateKey() {
191 * Sets the private key of the project.
194 * The private key of the project
196 void setPrivateKey(String privateKey) {
197 String oldPrivateKey = this.privateKey;
198 this.privateKey = privateKey;
199 fireIfPropertyChanged(PROPERTY_PRIVATE_KEY, oldPrivateKey, privateKey);
203 * Returns the base path of the project.
205 * @return The base path of the project
207 public String getBasePath() {
212 * Sets the base path of the project.
215 * The base path of the project
217 public void setBasePath(String basePath) {
218 String oldBasePath = this.basePath;
219 this.basePath = basePath;
220 fireIfPropertyChanged(PROPERTY_BASE_PATH, oldBasePath, basePath);
224 * Returns the default file.
226 * @return The default file
228 public String getDefaultFile() {
233 * Sets the default file.
238 public void setDefaultFile(String defaultFile) {
239 String oldDefaultFile = this.defaultFile;
240 this.defaultFile = defaultFile;
241 fireIfPropertyChanged(PROPERTY_DEFAULT_FILE, oldDefaultFile, defaultFile);
245 * Adds an override for the given file.
250 * The override for the file
252 public void addOverride(String filePath, Override override) {
253 overrides.put(filePath, override);
257 * Removes the override for the given file.
260 * The file path for which to remove the override
262 public void removeOverride(String filePath) {
263 overrides.remove(filePath);
267 * Returns the list of {@link Override}s.
269 * @return All overrides
271 public Map<String, Override> getOverrides() {
276 * Scans the base path for files and returns the {@link ProjectFile} for the
277 * base path. From this file it is possible to reach all files in the base
280 * This method is disk-intensive and may take some time on larger
283 * @return The file for the base path
285 public ProjectFile getBaseFile() {
290 * Implementation of a {@link ProjectFile}.
292 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
294 private static class ProjectFileImpl implements ProjectFile {
297 * @see net.pterodactylus.jsite.project.ProjectFile#getName()
299 public String getName() {
300 // TODO Auto-generated method stub
305 * @see net.pterodactylus.jsite.project.ProjectFile#getParents()
307 public List<ProjectFile> getParents() {
308 // TODO Auto-generated method stub
313 * @see net.pterodactylus.jsite.project.ProjectFile#isFile()
315 public boolean isFile() {
316 // TODO Auto-generated method stub
321 * @see net.pterodactylus.jsite.project.ProjectFile#isDirectory()
323 public boolean isDirectory() {
324 // TODO Auto-generated method stub
329 * @see net.pterodactylus.jsite.project.ProjectFile#isHidden()
331 public boolean isHidden() {
332 // TODO Auto-generated method stub
337 * @see net.pterodactylus.jsite.project.ProjectFile#getFiles()
339 public List<ProjectFile> getFiles() {
340 // TODO Auto-generated method stub