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