1e74eb21823689e550dde65238a219c6e285b69f
[hespiff.git] / src / main / java / org / hedgecode / xml / xspf / PlaylistFactory.java
1 /*
2  * Copyright (c) 2015. Developed by Hedgecode.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.hedgecode.xml.xspf;
18
19 import java.util.List;
20
21 import org.hedgecode.xml.xspf.bind.TrackBinder;
22
23 import static org.hedgecode.xml.xspf.XSPFConstants.Format;
24
25 /**
26  *
27  *
28  * @author Dmitry Samoshin aka gotty
29  */
30 public final class PlaylistFactory {
31
32     public static Playlist createPlaylist(Format format) {
33         return new XSPFPlaylist(format);
34     }
35
36     public static Track createTrack() {
37         return new XSPFTrack();
38     }
39
40     public static Track createTrack(TrackBinder trackBinder) {
41         XSPFTrack track = new XSPFTrack();
42         track.unbind(
43                 new XMLBindTrack(trackBinder)
44         );
45         return track;
46     }
47
48     public static void bindTrack(Track track, TrackBinder trackBinder) {
49         if (track instanceof XSPFTrack)
50             ((XSPFTrack)track).bind(
51                     new XMLBindTrack(trackBinder)
52             );
53     }
54
55     public static Attribution createAttribution() {
56         Attribution attribution = new XSPFAttribution();
57         return attribution;
58     }
59
60     public static Attribution createAttribution(String identifier, String location) {
61         Attribution attribution = new XSPFAttribution();
62         attribution.add(identifier, location);
63         return attribution;
64     }
65
66     public static Link createLink(String rel, String content) {
67         return new XSPFLink(rel, content);
68     }
69
70     public static Meta createMeta(String rel, String content) {
71         return new XSPFMeta(rel, content);
72     }
73
74     public static Extension createExtension(String application, List<Object> content) {
75         return new XSPFExtension(application, content);
76     }
77
78 }