View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  
23  package org.opencastproject.mediapackage;
24  
25  import org.w3c.dom.Node;
26  
27  import java.net.URI;
28  
29  /**
30   * A media package element builder provides factory methods for the creation and loading of media package elements from
31   * files.
32   */
33  public interface MediaPackageElementBuilder {
34  
35    /**
36     * Creates a media package element from the given file that was previously accepted.
37     * <p>
38     * Since only the file is given, it is possible, that the best builder plugin cannot be uniquely identified and may
39     * require additional contraints, e. g. a matching filename. Be sure to check the documentation of the corresponding
40     * plugin for details.
41     * </p>
42     *
43     * @param uri
44     *          the element location
45     * @return the new media package element
46     * @throws UnsupportedElementException
47     *           if creating the media package element fails
48     */
49    MediaPackageElement elementFromURI(URI uri) throws UnsupportedElementException;
50  
51    /**
52     * Creates a media package element from the given file that was previously accepted, while <code>type</code> and
53     * <code>flavor</code> may be taken as strong hints and may both be <code>null</code>.
54     * <p>
55     * If only the file is given, it is possible, that the best suited builder plugin cannot be uniquely identified and
56     * may require additional contraints, e. g. a matching filename. Be sure to check the documentation of the
57     * corresponding builder plugin for details.
58     * </p>
59     *
60     * @param uri
61     *          the element location
62     * @param type
63     *          the element type
64     * @param flavor
65     *          the element flavor
66     * @return the new media package element
67     * @throws UnsupportedElementException
68     *           if creating the media package element fails
69     */
70    MediaPackageElement elementFromURI(URI uri, MediaPackageElement.Type type, MediaPackageElementFlavor flavor)
71            throws UnsupportedElementException;
72  
73    /**
74     * Creates a media package element from the DOM element.
75     *
76     * @param elementNode
77     *          the DOM node
78     * @param serializer
79     *          the media package serializer
80     * @return the media package element
81     * @throws UnsupportedElementException
82     *           if reading the file from manifest fails
83     */
84    MediaPackageElement elementFromManifest(Node elementNode, MediaPackageSerializer serializer)
85            throws UnsupportedElementException;
86  
87    /**
88     * Creates a new media package elment of the specified type.
89     *
90     * @param type
91     *          the element type
92     * @param flavor
93     *          the element flavor
94     * @return the new media package element
95     */
96    MediaPackageElement newElement(MediaPackageElement.Type type, MediaPackageElementFlavor flavor);
97  
98  }