Coverage Report - org.jaudiotagger.tag.mp4.atom.Mp4NameBox
 
Classes in this File Line Coverage Branch Coverage Complexity
Mp4NameBox
88%
7/8
50%
1/2
2
 
 1  
 package org.jaudiotagger.tag.mp4.atom;
 2  
 
 3  
 import org.jaudiotagger.audio.generic.Utils;
 4  
 import org.jaudiotagger.audio.mp4.atom.AbstractMp4Box;
 5  
 import org.jaudiotagger.audio.mp4.atom.Mp4BoxHeader;
 6  
 
 7  
 import java.nio.ByteBuffer;
 8  
 
 9  
 /**
 10  
  * This box is used within ---- boxes to hold the data name/descriptor
 11  
  */
 12  
 public class Mp4NameBox extends AbstractMp4Box
 13  
 {
 14  
     public static final String IDENTIFIER = "name";
 15  
 
 16  
     private String name;
 17  
 
 18  
     //TODO Are these misnamed, are these version flag bytes or just null bytes
 19  
     public static final int VERSION_LENGTH = 1;
 20  
     public static final int FLAGS_LENGTH = 3;
 21  
     public static final int PRE_DATA_LENGTH = VERSION_LENGTH + FLAGS_LENGTH;
 22  
 
 23  
     /**
 24  
      * @param header     parentHeader info
 25  
      * @param dataBuffer data of box (doesnt include parentHeader data)
 26  
      */
 27  
     public Mp4NameBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
 28  450
     {
 29  450
         this.header = header;
 30  
 
 31  
         //Double check
 32  450
         if (!header.getId().equals(IDENTIFIER))
 33  
         {
 34  0
             throw new RuntimeException("Unable to process name box because identifier is:" + header.getId());
 35  
         }
 36  
 
 37  
         //Make slice so operations here don't effect position of main buffer
 38  450
         this.dataBuffer = dataBuffer.slice();
 39  
 
 40  
         //issuer
 41  450
         this.name = Utils.getString(this.dataBuffer, PRE_DATA_LENGTH, header.getDataLength() - PRE_DATA_LENGTH, header.getEncoding());
 42  450
     }
 43  
 
 44  
     public String getName()
 45  
     {
 46  450
         return name;
 47  
     }
 48  
 }