1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.support.model.container;
17
18 import org.fourthline.cling.support.model.item.Item;
19 import org.fourthline.cling.support.model.item.Photo;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24
25
26
27 public class PhotoAlbum extends Album {
28
29 public static final Class CLASS = new Class("object.container.album.photoAlbum");
30
31 public PhotoAlbum() {
32 setClazz(CLASS);
33 }
34
35 public PhotoAlbum(Container other) {
36 super(other);
37 }
38
39 public PhotoAlbum(String id, Container parent, String title, String creator, Integer childCount) {
40 this(id, parent.getId(), title, creator, childCount, new ArrayList<Photo>());
41 }
42
43 public PhotoAlbum(String id, Container parent, String title, String creator, Integer childCount, List<Photo> photos) {
44 this(id, parent.getId(), title, creator, childCount, photos);
45 }
46
47 public PhotoAlbum(String id, String parentID, String title, String creator, Integer childCount) {
48 this(id, parentID, title, creator, childCount, new ArrayList<Photo>());
49 }
50
51 public PhotoAlbum(String id, String parentID, String title, String creator, Integer childCount, List<Photo> photos) {
52 super(id, parentID, title, creator, childCount);
53 setClazz(CLASS);
54 addPhotos(photos);
55 }
56
57 public Photo[] getPhotos() {
58 List<Photo> list = new ArrayList<>();
59 for (Item item : getItems()) {
60 if (item instanceof Photo) list.add((Photo)item);
61 }
62 return list.toArray(new Photo[list.size()]);
63 }
64
65 public void addPhotos(List<Photo> photos) {
66 addPhotos(photos.toArray(new Photo[photos.size()]));
67 }
68
69 public void addPhotos(Photo[] photos) {
70 if (photos != null) {
71 for (Photo photo : photos) {
72 photo.setAlbum(getTitle());
73 addItem(photo);
74 }
75 }
76 }
77
78 }