Coverage Report - org.jaudiotagger.audio.asf.io.AsfExtHeaderReader
 
Classes in this File Line Coverage Branch Coverage Complexity
AsfExtHeaderReader
100%
10/10
20%
2/10
0
 
 1  
 package org.jaudiotagger.audio.asf.io;
 2  
 
 3  
 import org.jaudiotagger.audio.asf.data.AsfExtendedHeader;
 4  
 import org.jaudiotagger.audio.asf.data.GUID;
 5  
 import org.jaudiotagger.audio.asf.util.Utils;
 6  
 
 7  
 import java.io.IOException;
 8  
 import java.io.InputStream;
 9  
 import java.math.BigInteger;
 10  
 import java.util.List;
 11  
 
 12  
 /**
 13  
  * This reader reads an ASF header extension object from an {@link InputStream} and creates an
 14  
  * {@link AsfExtendedHeader} object.<br>
 15  
  * 
 16  
  * @author Christian Laireiter
 17  
  */
 18  122
 public class AsfExtHeaderReader extends ChunkContainerReader<AsfExtendedHeader>
 19  
 {
 20  
 
 21  
     /**
 22  
      * Creates a reader instance, which only utilizes the given list of chunk
 23  
      * readers.<br>
 24  
      * 
 25  
      * @param toRegister
 26  
      *            List of {@link ChunkReader} class instances, which are to be
 27  
      *            utilized by the instance.
 28  
      * @param readChunkOnce
 29  
      *            if <code>true</code>, each chunk type (identified by chunk
 30  
      *            GUID) will handled only once, if a reader is available, other
 31  
      *            chunks will be discarded.
 32  
      */
 33  
     public AsfExtHeaderReader(List<Class<? extends ChunkReader>> toRegister, boolean readChunkOnce)
 34  
     {
 35  126
         super(toRegister, readChunkOnce);
 36  126
     }
 37  
 
 38  
     /**
 39  
      * {@inheritDoc}
 40  
      */
 41  
     @Override
 42  
     protected AsfExtendedHeader createContainer(long streamPosition, BigInteger chunkLength, InputStream stream) throws IOException
 43  
     {
 44  80
         Utils.readGUID(stream); // First reserved field (should be a specific GUID.
 45  80
         Utils.readUINT16(stream); // Second reserved field (should always be 6)
 46  80
         final long extensionSize = Utils.readUINT32(stream);
 47  80
         assert extensionSize == 0 || extensionSize >= 24;
 48  80
         assert chunkLength.subtract(BigInteger.valueOf(46)).longValue() == extensionSize;
 49  80
         return new AsfExtendedHeader(streamPosition, chunkLength);
 50  
     }
 51  
 
 52  
     /**
 53  
      * {@inheritDoc}
 54  
      */
 55  
     public GUID getApplyingId()
 56  
     {
 57  206
         return GUID.GUID_HEADER_EXTENSION;
 58  
     }
 59  
 
 60  
 
 61  
 }