Skip to content

Commit cf6fc59

Browse files
Merge pull request commons-app#1011 from claytsay/master
Google Code-In 2017: Added JavaDocs
2 parents bdcd2ac + 40f9db4 commit cf6fc59

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

app/src/main/java/fr/free/nrw/commons/License.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ public class License {
88
private String url;
99
private String name;
1010

11+
/**
12+
* Constructs a new instance of License.
13+
*
14+
* @param key license key
15+
* @param template license template
16+
* @param url license URL
17+
* @param name licence name
18+
*
19+
* @throws RuntimeException if License.key or Licence.template is null
20+
*/
1121
public License(String key, String template, String url, String name) {
1222
if (key == null) {
1323
throw new RuntimeException("License.key must not be null");
@@ -21,10 +31,18 @@ public License(String key, String template, String url, String name) {
2131
this.name = name;
2232
}
2333

34+
/**
35+
* Gets the license key.
36+
* @return license key as a String.
37+
*/
2438
public String getKey() {
2539
return key;
2640
}
2741

42+
/**
43+
* Gets the license template.
44+
* @return license template as a String.
45+
*/
2846
public String getTemplate() {
2947
return template;
3048
}

app/src/main/java/fr/free/nrw/commons/Media.java

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,89 +128,177 @@ public String getImageUrl() {
128128
return imageUrl;
129129
}
130130

131+
/**
132+
* Gets the name of the file.
133+
* @return file name as a string
134+
*/
131135
public String getFilename() {
132136
return filename;
133137
}
134138

139+
/**
140+
* Sets the name of the file.
141+
* @param filename the new name of the file
142+
*/
135143
public void setFilename(String filename) {
136144
this.filename = filename;
137145
}
138146

147+
/**
148+
* Gets the file description.
149+
* @return file description as a string
150+
*/
139151
public String getDescription() {
140152
return description;
141153
}
142154

155+
/**
156+
* Sets the file description.
157+
* @param description the new description of the file
158+
*/
143159
public void setDescription(String description) {
144160
this.description = description;
145161
}
146162

163+
/**
164+
* Gets the datalength of the file.
165+
* @return file datalength as a long
166+
*/
147167
public long getDataLength() {
148168
return dataLength;
149169
}
150170

171+
/**
172+
* Sets the datalength of the file.
173+
* @param dataLength as a long
174+
*/
151175
public void setDataLength(long dataLength) {
152176
this.dataLength = dataLength;
153177
}
154178

179+
/**
180+
* Gets the creation date of the file.
181+
* @return creation date as a Date
182+
*/
155183
public Date getDateCreated() {
156184
return dateCreated;
157185
}
158186

187+
/**
188+
* Sets the creation date of the file.
189+
* @param date creation date as a Date
190+
*/
159191
public void setDateCreated(Date date) {
160192
this.dateCreated = date;
161193
}
162194

195+
/**
196+
* Gets the upload date of the file.
197+
* Can be null.
198+
* @return upload date as a Date
199+
*/
163200
public @Nullable
164201
Date getDateUploaded() {
165202
return dateUploaded;
166203
}
167204

205+
/**
206+
* Gets the name of the creator of the file.
207+
* @return creator name as a String
208+
*/
168209
public String getCreator() {
169210
return creator;
170211
}
171212

213+
/**
214+
* Sets the creator name of the file.
215+
* @param creator creator name as a string
216+
*/
172217
public void setCreator(String creator) {
173218
this.creator = creator;
174219
}
175220

221+
/**
222+
* Gets the width of the media.
223+
* @return file width as an int
224+
*/
176225
public int getWidth() {
177226
return width;
178227
}
179228

229+
/**
230+
* Sets the width of the media.
231+
* @param width file width as an int
232+
*/
180233
public void setWidth(int width) {
181234
this.width = width;
182235
}
183236

237+
/**
238+
* Gets the height of the media.
239+
* @return file height as an int
240+
*/
184241
public int getHeight() {
185242
return height;
186243
}
187244

245+
/**
246+
* Sets the height of the media.
247+
* @param height file height as an int
248+
*/
188249
public void setHeight(int height) {
189250
this.height = height;
190251
}
191252

253+
/**
254+
* Gets the license name of the file.
255+
* @return license as a String
256+
*/
192257
public String getLicense() {
193258
return license;
194259
}
195260

261+
/**
262+
* Sets the license name of the file.
263+
* @param license license name as a String
264+
*/
196265
public void setLicense(String license) {
197266
this.license = license;
198267
}
199268

269+
/**
270+
* Gets the coordinates of where the file was created.
271+
* @return file coordinates as a LatLng
272+
*/
200273
public @Nullable
201274
LatLng getCoordinates() {
202275
return coordinates;
203276
}
204277

278+
/**
279+
* Sets the coordinates of where the file was created.
280+
* @param coordinates file coordinates as a LatLng
281+
*/
205282
public void setCoordinates(@Nullable LatLng coordinates) {
206283
this.coordinates = coordinates;
207284
}
208285

286+
/**
287+
* Gets the categories the file falls under.
288+
* @return file categories as an ArrayList of Strings
289+
*/
209290
@SuppressWarnings("unchecked")
210291
public ArrayList<String> getCategories() {
211292
return (ArrayList<String>) categories.clone(); // feels dirty
212293
}
213294

295+
/**
296+
* Sets the categories the file falls under.
297+
* </p>
298+
* Does not append: i.e. will clear the current categories
299+
* and then add the specified ones.
300+
* @param categories file categories as a list of Strings
301+
*/
214302
public void setCategories(List<String> categories) {
215303
this.categories.clear();
216304
this.categories.addAll(categories);

app/src/main/java/fr/free/nrw/commons/PageTitle.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public String getText() {
8484
return titleKey;
8585
}
8686

87+
/**
88+
* Gets the canonicalized title for displaying (such as "File:My example.jpg").
89+
* </p>
90+
* Essentially equivalent to getPrefixedText
91+
* @return canonical title as a String
92+
*/
8793
@Override
8894
public String toString() {
8995
return getPrefixedText();

app/src/main/java/fr/free/nrw/commons/Utils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public static String urlEncode(String url) {
5151
}
5252
}
5353

54+
/**
55+
* Capitalizes the first character of a string.
56+
*
57+
* @param string
58+
* @return string with capitalized first character
59+
*/
5460
public static String capitalize(String string) {
5561
return string.substring(0, 1).toUpperCase(Locale.getDefault()) + string.substring(1);
5662
}

0 commit comments

Comments
 (0)