Coverage Report - org.jaudiotagger.audio.flac.FlacStreamReader
 
Classes in this File Line Coverage Branch Coverage Complexity
FlacStream
80%
8/10
75%
3/4
5
 
 1  
 package org.jaudiotagger.audio.flac;
 2  
 
 3  
 import org.jaudiotagger.audio.exceptions.CannotReadException;
 4  
 
 5  
 import java.io.RandomAccessFile;
 6  
 import java.io.IOException;
 7  
 
 8  
 /**
 9  
  * Flac Stream
 10  
  * <p/>
 11  
  * Identifies this is in fact a flac stream
 12  
  */
 13  0
 public class FlacStream
 14  
 {
 15  
     public static final int FLAC_STREAM_IDENTIFIER_LENGTH = 4;
 16  
     public static final String FLAC_STREAM_IDENTIFIER = "fLaC";
 17  
 
 18  
     /**
 19  
      * Reads the stream block to ensure it is a flac file
 20  
      *
 21  
      * @param raf
 22  
      * @throws IOException
 23  
      * @throws CannotReadException
 24  
      */
 25  
     public static void findStream(RandomAccessFile raf) throws IOException, CannotReadException
 26  
     {
 27  
         //Begins tag parsing
 28  28
         if (raf.length() == 0)
 29  
         {
 30  
             //Empty File
 31  0
             throw new CannotReadException("Error: File empty");
 32  
         }
 33  28
         raf.seek(0);
 34  
 
 35  
         //FLAC Stream
 36  28
         byte[] b = new byte[FlacStream.FLAC_STREAM_IDENTIFIER_LENGTH];
 37  28
         raf.read(b);
 38  28
         String flac = new String(b);
 39  28
         if (!flac.equals(FlacStream.FLAC_STREAM_IDENTIFIER))
 40  
         {
 41  1
             throw new CannotReadException("fLaC Header not found, not a flac file");
 42  
         }
 43  
 
 44  27
     }
 45  
 }