-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTagManager.java
More file actions
50 lines (44 loc) · 1.33 KB
/
Copy pathTagManager.java
File metadata and controls
50 lines (44 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package photo_renamer;
import java.io.*;
import java.util.ArrayList;
/** A manager for Tag database. */
class TagManager extends AbstractDatabaseManager {
/** The ArrayList containing the managed Tags. */
ArrayList<Tag> tags;
/**
* Construct a TagManager for the database of Tags.
*
* @param tagsPath the pathname to save the tag list
* @throws IOException an IOException exception
* @throws ClassNotFoundException a ClassNotFoundException exception
*/
@SuppressWarnings("unchecked")
TagManager(String tagsPath) throws IOException, ClassNotFoundException {
super(tagsPath);
this.tags = super.managedObjects;
}
/**
* Add a new Tag to the managed database of Tags.
*
* @param newTag the Tag to be added
* @throws IOException an IOException exception
*/
void addTag(Tag newTag) throws IOException {
if (!tags.contains(newTag)) {
tags.add(newTag);
toFile();
}
}
/**
* Remove a Tag from the managed database of Tags.
*
* @param oldTag the Tag to be removed
* @throws IOException an IOException exception
*/
void removeTag(Tag oldTag) throws IOException {
if (tags.contains(oldTag)) {
tags.remove(oldTag);
toFile();
}
}
}