com.coremedia.iso.boxes
Class FullContainerBox

java.lang.Object
  extended by com.coremedia.iso.boxes.AbstractBox
      extended by com.coremedia.iso.boxes.AbstractFullBox
          extended by com.coremedia.iso.boxes.FullContainerBox
All Implemented Interfaces:
Box, ContainerBox, FullBox
Direct Known Subclasses:
DataReferenceBox, ItemProtectionBox, SampleDescriptionBox

public abstract class FullContainerBox
extends AbstractFullBox
implements ContainerBox

Abstract base class for a full iso box only containing ither boxes.


Field Summary
protected  List<Box> boxes
           
 
Fields inherited from class com.coremedia.iso.boxes.AbstractBox
deadBytes, type
 
Constructor Summary
FullContainerBox(String type)
           
 
Method Summary
 void _parseDetails(ByteBuffer content)
          Implement the actual parsing of the box's fields here.
 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(ByteBuffer bb)
          Writes the box's content into the given ByteBuffer.
protected  long getContentSize()
          Gets the box's content size.
 long getNumOfBytesToFirstChild()
          Returns the number of bytes from the start of the box to start of the first child.
 void parse(ReadableByteChannel in, ByteBuffer header, long contentSize, BoxParser boxParser)
          Pareses the given IsoBufferWrapper and returns the remaining bytes.
protected  void parseChildBoxes(ByteBuffer content)
           
 void removeBox(Box b)
           
 void setBoxes(List<Box> boxes)
          Sets all boxes and removes all previous child boxes.
 String toString()
           
protected  void writeChildBoxes(ByteBuffer bb)
           
 
Methods inherited from class com.coremedia.iso.boxes.AbstractFullBox
getFlags, getVersion, parseVersionAndFlags, setFlags, setVersion, writeVersionAndFlags
 
Methods inherited from class com.coremedia.iso.boxes.AbstractBox
getBox, getDeadBytes, getHeader, getIsoFile, getParent, getSize, getType, getUserType, isParsed, parseDetails, setDeadBytes, setParent, setUserType
 
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
getBox, getSize, getType, setParent
 

Field Detail

boxes

protected List<Box> boxes
Constructor Detail

FullContainerBox

public FullContainerBox(String type)
Method Detail

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.

getContentSize

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

Flags and version of a full box need to be taken into account.

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

addBox

public void addBox(Box b)

removeBox

public void removeBox(Box b)

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.

parse

public void parse(ReadableByteChannel in,
                  ByteBuffer header,
                  long contentSize,
                  BoxParser boxParser)
           throws IOException
Description copied from class: AbstractBox
Pareses the given IsoBufferWrapper and returns the remaining bytes.

Specified by:
parse in interface Box
Overrides:
parse in class AbstractBox
Parameters:
in - the (part of the) iso file to parse
contentSize - expected contentSize of the box
boxParser - creates inner boxes
Throws:
IOException - in case of an I/O error.

_parseDetails

public void _parseDetails(ByteBuffer content)
Description copied from class: AbstractBox
Implement the actual parsing of the box's fields here. External classes will always call AbstractBox.parseDetails() which encapsulates the call to this method with some safeguards.

Specified by:
_parseDetails in class AbstractBox

parseChildBoxes

protected final void parseChildBoxes(ByteBuffer content)

toString

public String toString()
Overrides:
toString in class Object

getContent

protected void getContent(ByteBuffer bb)
                   throws IOException
Description copied from class: AbstractBox
Writes the box's content into the given ByteBuffer. This must include flags and version in case of a full box. bb has been initialized with getSize() bytes.

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

writeChildBoxes

protected final void writeChildBoxes(ByteBuffer bb)
                              throws IOException
Throws:
IOException

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 © 2012. All Rights Reserved.