1/*
2 * Copyright 2008 CoreMedia AG, Hamburg
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
17package com.coremedia.iso.boxes;
18
19import com.coremedia.iso.IsoFile;
20
21import java.util.List;
22
23/**
24 * Interface for all ISO boxes that may contain other boxes.
25 */
26public interface ContainerBox extends Box {
27
28    /**
29     * Gets all child boxes. May not return <code>null</code>.
30     *
31     * @return an array of boxes, empty array in case of no children.
32     */
33    List<Box> getBoxes();
34
35    /**
36     * Sets all boxes and removes all previous child boxes.
37     * @param boxes the new list of children
38     */
39    void setBoxes(List<Box> boxes);
40
41    /**
42     * Gets all child boxes of the given type. May not return <code>null</code>.
43     *
44     * @param clazz child box's type
45     * @return an array of boxes, empty array in case of no children.
46     */
47    <T extends Box> List<T> getBoxes(Class<T> clazz);
48
49    /**
50     * Gets all child boxes of the given type. May not return <code>null</code>.
51     *
52     * @param clazz     child box's type
53     * @param recursive step down the tree
54     * @return an array of boxes, empty array in case of no children.
55     */
56    <T extends Box> List<T> getBoxes(Class<T> clazz, boolean recursive);
57
58    /**
59     * Gets the parent box. May be <code>null</code> in case of the
60     * {@link com.coremedia.iso.IsoFile} itself.
61     *
62     * @return a <code>ContainerBox</code> that contains <code>this</code>
63     */
64    ContainerBox getParent();
65
66    /**
67     * Returns the number of bytes from the start of the box to start of the first child.
68     *
69     * @return offset of first child from box start
70     */
71    long getNumOfBytesToFirstChild();
72
73    IsoFile getIsoFile();
74}
75