com.coremedia.iso.boxes
Class AbstractContainerBox

java.lang.Object
  extended by com.coremedia.iso.boxes.AbstractBox
      extended by com.coremedia.iso.boxes.AbstractContainerBox
All Implemented Interfaces:
Box, ContainerBox
Direct Known Subclasses:
AppleGenericBox, AppleItemListBox, AppleReferenceMovieBox, AppleReferenceMovieDescriptorBox, AppleWaveBox, DataInformationBox, EditBox, HintInformationBox, HintStatisticsBox, IsoFile, MediaBox, MediaInformationBox, MovieBox, MovieExtendsBox, MovieFragmentBox, MovieFragmentRandomAccessBox, MutableDrmInformationBox, ProtectionSchemeInformationBox, SampleTableBox, SchemeInformationBox, TrackBox, TrackFragmentBox, TrackReferenceBox, UserDataBox

public abstract class AbstractContainerBox
extends AbstractBox
implements ContainerBox

Abstract base class suitable for most boxes acting purely as container for other boxes.


Field Summary
protected  List<Box> boxes
           
 
Fields inherited from class com.coremedia.iso.boxes.AbstractBox
offset, parsed
 
Constructor Summary
AbstractContainerBox(byte[] type)
           
 
Method Summary
 void addBox(Box b)
           
 List<Box> getBoxes()
          Gets all child boxes.
<T extends Box>
List<T>
getBoxes(Class<T> clazz)
          Gets all child boxes of the given type.
<T extends Box>
List<T>
getBoxes(Class<T> clazz, boolean recursive)
          Gets all child boxes of the given type.
protected  void getContent(IsoOutputStream os)
          Writes the box's content into the given IsoOutputStream.
protected  long getContentSize()
          Gets the box's content size without header size.
 long getNumOfBytesToFirstChild()
          Returns the number of bytes from the start of the box to start of the first child.
 void parse(IsoBufferWrapper in, long size, BoxParser boxParser, Box lastMovieFragmentBox)
          Pareses the given IsoBufferWrapper and returns the remaining bytes.
 void removeBox(Box b)
           
 void setBoxes(List<Box> boxes)
          Sets all boxes and removes all previous child boxes.
 String toString()
           
 
Methods inherited from class com.coremedia.iso.boxes.AbstractBox
addWriteListener, calculateOffset, getBox, getDeadBytes, getDisplayName, getHeader, getHeaderSize, getIsoFile, getOffset, getParent, getSize, getType, getUserType, isParsed, setDeadBytes, setParent, setParsed, setUserType, utf8StringLengthInBytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.coremedia.iso.boxes.ContainerBox
getIsoFile, getParent
 
Methods inherited from interface com.coremedia.iso.boxes.Box
calculateOffset, getBox, getOffset, getSize, getType, getUserType, isParsed
 

Field Detail

boxes

protected List<Box> boxes
Constructor Detail

AbstractContainerBox

public AbstractContainerBox(byte[] type)
Method Detail

getContentSize

protected long getContentSize()
Description copied from class: AbstractBox
Gets the box's content size without header size.

Specified by:
getContentSize in class AbstractBox
Returns:
Gets the box's content size in bytes

getBoxes

public List<Box> getBoxes()
Description copied from interface: ContainerBox
Gets all child boxes. May not return null.

Specified by:
getBoxes in interface ContainerBox
Returns:
an array of boxes, empty array in case of no children.

setBoxes

public void setBoxes(List<Box> boxes)
Description copied from interface: ContainerBox
Sets all boxes and removes all previous child boxes.

Specified by:
setBoxes in interface ContainerBox
Parameters:
boxes - the new list of children

getBoxes

public <T extends Box> List<T> getBoxes(Class<T> clazz)
Description copied from interface: ContainerBox
Gets all child boxes of the given type. May not return null.

Specified by:
getBoxes in interface ContainerBox
Parameters:
clazz - child box's type
Returns:
an array of boxes, empty array in case of no children.

getBoxes

public <T extends Box> List<T> getBoxes(Class<T> clazz,
                                        boolean recursive)
Description copied from interface: ContainerBox
Gets all child boxes of the given type. May not return null.

Specified by:
getBoxes in interface ContainerBox
Parameters:
clazz - child box's type
recursive - step down the tree
Returns:
an array of boxes, empty array in case of no children.

addBox

public void addBox(Box b)

removeBox

public void removeBox(Box b)

parse

public void parse(IsoBufferWrapper in,
                  long size,
                  BoxParser boxParser,
                  Box lastMovieFragmentBox)
           throws IOException
Description copied from class: AbstractBox
Pareses the given IsoBufferWrapper and returns the remaining bytes.

Specified by:
parse in class AbstractBox
Parameters:
in - the (part of the) iso file to parse
size - expected size of the box
boxParser - creates inner boxes
lastMovieFragmentBox - latest of previously found moof boxes
Throws:
IOException - in case of an I/O error.

getContent

protected void getContent(IsoOutputStream os)
                   throws IOException
Description copied from class: AbstractBox
Writes the box's content into the given IsoOutputStream. This MUST NOT include any header bytes.

Specified by:
getContent in class AbstractBox
Parameters:
os - the box's content-sink.
Throws:
IOException - in case of an exception in the underlying OutputStream.

toString

public String toString()
Overrides:
toString in class Object

getNumOfBytesToFirstChild

public long getNumOfBytesToFirstChild()
Description copied from interface: ContainerBox
Returns the number of bytes from the start of the box to start of the first child.

Specified by:
getNumOfBytesToFirstChild in interface ContainerBox
Returns:
offset of first child from box start


Copyright © 2011. All Rights Reserved.