Coverage Report - org.jaudiotagger.audio.asf.io.FileHeaderReader
 
Classes in this File Line Coverage Branch Coverage Complexity
FileHeaderReader
100%
20/20
N/A
1
 
 1  
 /*
 2  
  * Entagged Audio Tag library
 3  
  * Copyright (c) 2004-2005 Christian Laireiter <liree@web.de>
 4  
  * 
 5  
  * This library is free software; you can redistribute it and/or
 6  
  * modify it under the terms of the GNU Lesser General Public
 7  
  * License as published by the Free Software Foundation; either
 8  
  * version 2.1 of the License, or (at your option) any later version.
 9  
  *  
 10  
  * This library is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
  * Lesser General Public License for more details.
 14  
  * 
 15  
  * You should have received a copy of the GNU Lesser General Public
 16  
  * License along with this library; if not, write to the Free Software
 17  
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 18  
  */
 19  
 package org.jaudiotagger.audio.asf.io;
 20  
 
 21  
 import org.jaudiotagger.audio.asf.data.Chunk;
 22  
 import org.jaudiotagger.audio.asf.data.FileHeader;
 23  
 import org.jaudiotagger.audio.asf.data.GUID;
 24  
 import org.jaudiotagger.audio.asf.util.Utils;
 25  
 
 26  
 import java.io.IOException;
 27  
 import java.io.InputStream;
 28  
 import java.math.BigInteger;
 29  
 
 30  
 /**
 31  
  * Reads and interprets the data of the file header. <br>
 32  
  * 
 33  
  * @author Christian Laireiter
 34  
  */
 35  
 public class FileHeaderReader implements ChunkReader {
 36  
 
 37  
     /**
 38  
      * The GUID this reader {@linkplain #getApplyingIds() applies to}
 39  
      */
 40  4
     private final static GUID[] APPLYING = { GUID.GUID_FILE };
 41  
 
 42  
     /**
 43  
      * Should not be used for now.
 44  
      */
 45  12
     protected FileHeaderReader() {
 46  
         // NOTHING toDo
 47  12
     }
 48  
 
 49  
     /**
 50  
      * {@inheritDoc}
 51  
      */
 52  
     public boolean canFail() {
 53  278
         return false;
 54  
     }
 55  
 
 56  
     /**
 57  
      * {@inheritDoc}
 58  
      */
 59  
     public GUID[] getApplyingIds() {
 60  12
         return APPLYING.clone();
 61  
     }
 62  
 
 63  
     /**
 64  
      * {@inheritDoc}
 65  
      */
 66  
     public Chunk read(final GUID guid, final InputStream stream,
 67  
             final long chunkStart) throws IOException {
 68  278
         final BigInteger chunkLen = Utils.readBig64(stream);
 69  
         // Skip client GUID.
 70  278
         stream.skip(16);
 71  278
         final BigInteger fileSize = Utils.readBig64(stream);
 72  
         // fileTime in 100 ns since midnight of 1st january 1601 GMT
 73  278
         final BigInteger fileTime = Utils.readBig64(stream);
 74  
 
 75  278
         final BigInteger packageCount = Utils.readBig64(stream);
 76  
 
 77  278
         final BigInteger timeEndPos = Utils.readBig64(stream);
 78  278
         final BigInteger duration = Utils.readBig64(stream);
 79  278
         final BigInteger timeStartPos = Utils.readBig64(stream);
 80  
 
 81  278
         final long flags = Utils.readUINT32(stream);
 82  
 
 83  278
         final long minPkgSize = Utils.readUINT32(stream);
 84  278
         final long maxPkgSize = Utils.readUINT32(stream);
 85  278
         final long uncompressedFrameSize = Utils.readUINT32(stream);
 86  
 
 87  278
         final FileHeader result = new FileHeader(chunkLen, fileSize, fileTime,
 88  
                 packageCount, duration, timeStartPos, timeEndPos, flags,
 89  
                 minPkgSize, maxPkgSize, uncompressedFrameSize);
 90  278
         result.setPosition(chunkStart);
 91  278
         return result;
 92  
     }
 93  
 
 94  
 }