Coverage Report - org.jaudiotagger.tag.id3.framebody.FrameBodyCTOC
 
Classes in this File Line Coverage Branch Coverage Complexity
FrameBodyCTOC
0%
0/9
N/A
1
 
 1  
 /*
 2  
  * Horizon Wimba Copyright (C)2006
 3  
  *
 4  
  * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
 5  
  * General Public  License as published by the Free Software Foundation; either version 2.1 of the License,
 6  
  * or (at your option) any later version.
 7  
  *
 8  
  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 9  
  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 10  
  * See the GNU Lesser General Public License for more details.
 11  
  *
 12  
  * You should have received a copy of the GNU Lesser General Public License along with this library; if not,
 13  
  * you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
 14  
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 15  
  */
 16  
 package org.jaudiotagger.tag.id3.framebody;
 17  
 
 18  
 import org.jaudiotagger.tag.InvalidTagException;
 19  
 import org.jaudiotagger.tag.datatype.ByteArraySizeTerminated;
 20  
 import org.jaudiotagger.tag.datatype.DataTypes;
 21  
 import org.jaudiotagger.tag.id3.ID3v2ChapterFrames;
 22  
 
 23  
 import java.nio.ByteBuffer;
 24  
 
 25  
 /**
 26  
  * Table of content frame.
 27  
  * <p/>
 28  
  * <p/>
 29  
  * The purpose of "CTOC" frames is to allow a table of contents to be
 30  
  * defined. In the simplest case, a single "CTOC" frame can be used to
 31  
  * provide a flat (single-level) table of contents. However, multiple
 32  
  * "CTOC" frames can also be used to define a hierarchical (multi-level)
 33  
  * table of contents.
 34  
  * </p><p>
 35  
  * There may be more than one frame of this type in a tag but each must
 36  
  * have an Element ID that is unique with respect to any other "CTOC" or
 37  
  * "CHAP" frame in the tag.
 38  
  * </p><p>
 39  
  * Each "CTOC" frame represents one level or element of a table of contents
 40  
  * by providing a list of Child Element IDs. These match the Element IDs of
 41  
  * other "CHAP" and "CTOC" frames in the tag.
 42  
  * </p>
 43  
  * <table border="0" width="70%" align="center">
 44  
  * <tr><td nowrap="nowrap">&lt;ID3v2.3 or ID3v2.4 frame header, ID: "CTOC"&gt;</td><td rowspan="7">&nbsp;&nbsp;</td><td>(10 bytes)</td></tr>
 45  
  * <tr><td>Element ID</td><td width="70%">&lt;text string&gt; $00</td></tr>
 46  
  * <tr><td>Flags</td><td>%000000ab</td></tr>
 47  
  * <tr><td>Entry count</td><td>$xx&nbsp;&nbsp;(8-bit unsigned int)</td></tr>
 48  
  * <tr><td>&lt;Child Element ID list&gt;</td></tr>
 49  
  * <tr><td>&lt;Optional embedded sub-frames&gt;</td></tr>
 50  
  * </table>
 51  
  * <p/>
 52  
  * The Element ID uniquely identifies the frame. It is not intended to
 53  
  * be human readable and should not be presented to the end-user.
 54  
  * </p><p>
 55  
  * Flag a - Top-level bit<br>
 56  
  * This is set to 1 to identify the top-level "CTOC" frame. This frame
 57  
  * is the root of the Table of Contents tree and is not a child of any
 58  
  * other "CTOC" frame. Only one "CTOC" frame in an ID3v2 tag can have
 59  
  * this bit set to 1. In all other "CTOC" frames this bit shall be set
 60  
  * to 0.
 61  
  * </p><p>
 62  
  * Flag b - Ordered bit<br>
 63  
  * This should be set to 1 if the entries in the Child Element ID list
 64  
  * are ordered or set to 0 if they not are ordered. This provides a hint
 65  
  * as to whether the elements should be played as a continuous ordered
 66  
  * sequence or played individually.
 67  
  * </p><p>
 68  
  * The Entry count is the number of entries in the Child Element ID list
 69  
  * that follows and must be greater than zero. Each entry in the list
 70  
  * consists of:
 71  
  * </p>
 72  
  * <table border="0" width="70%" align="center">
 73  
  * <tr><td nowrap="nowrap">Child Element ID</td><td>&nbsp;&nbsp;</td><td width="70%">&lt;text string&gt; $00</td></tr>
 74  
  * </table>
 75  
  * <p/>
 76  
  * The last entry in the child Element ID list is followed by a sequence
 77  
  * of optional frames that are embedded within the "CTOC" frame and which
 78  
  * describe this element of the table of contents (e.g. a "TIT2" frame
 79  
  * representing the name of the element) or provide related material such
 80  
  * as URLs and images. These sub-frames are contained within the bounds
 81  
  * of the "CTOC" frame as signalled by the size field in the "CTOC"
 82  
  * frame header.
 83  
  * </p><p>
 84  
  * If a parser does not recognise "CTOC" frames it can skip them using
 85  
  * the size field in the frame header. When it does this it will skip
 86  
  * any embedded sub-frames carried within the frame.
 87  
  * </p>
 88  
  * <p/>
 89  
  * <p>For more details, please refer to the ID3 Chapter Frame specifications:
 90  
  * <ul>
 91  
  * <li><a href="http://www.id3.org/id3v2-chapters-1.0.txt">ID3 v2 Chapter Frame Spec</a>
 92  
  * </ul>
 93  
  *
 94  
  * @author Marc Gimpel, Horizon Wimba S.A.
 95  
  * @version $Id: FrameBodyCTOC.java 832 2009-11-12 13:25:38Z paultaylor $
 96  
  */
 97  
 public class FrameBodyCTOC extends AbstractID3v2FrameBody implements ID3v2ChapterFrameBody
 98  
 {
 99  
     /**
 100  
      * Creates a new FrameBodyCTOC datatype.
 101  
      */
 102  
     public FrameBodyCTOC()
 103  0
     {
 104  0
     }
 105  
 
 106  
     /**
 107  
      * Creates a new FrameBodyCTOC datatype.
 108  
      *
 109  
      * @param body
 110  
      */
 111  
     public FrameBodyCTOC(FrameBodyCTOC body)
 112  
     {
 113  0
         super(body);
 114  0
     }
 115  
 
 116  
     /**
 117  
      * Creates a new FrameBodyCTOC datatype.
 118  
      *
 119  
      * @param byteBuffer
 120  
      * @param frameSize
 121  
      * @throws InvalidTagException if unable to create framebody from buffer
 122  
      */
 123  
     public FrameBodyCTOC(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException
 124  
     {
 125  0
         super(byteBuffer, frameSize);
 126  0
     }
 127  
 
 128  
     /**
 129  
      * The ID3v2 frame identifier
 130  
      *
 131  
      * @return the ID3v2 frame identifier  for this frame type
 132  
      */
 133  
     public String getIdentifier()
 134  
     {
 135  0
         return ID3v2ChapterFrames.FRAME_ID_TABLE_OF_CONTENT;
 136  
     }
 137  
 
 138  
     /**
 139  
      * TODO:proper mapping
 140  
      */
 141  
     protected void setupObjectList()
 142  
     {
 143  0
         objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_DATA, this));
 144  0
     }
 145  
 }