Coverage Report - org.jaudiotagger.audio.asf.io.FileHeaderReader
 
Classes in this File Line Coverage Branch Coverage Complexity
FileHeaderReader
100%
19/19
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  
     /**
 39  
      * Should not be used for now.
 40  
      */
 41  
     protected FileHeaderReader()
 42  126
     {
 43  
         // NOTHING toDo
 44  126
     }
 45  
 
 46  
     /**
 47  
      * {@inheritDoc}
 48  
      */
 49  
     public boolean canFail()
 50  
     {
 51  55
         return false;
 52  
     }
 53  
 
 54  
     /**
 55  
      * {@inheritDoc}
 56  
      */
 57  
     public GUID getApplyingId()
 58  
     {
 59  126
         return GUID.GUID_FILE;
 60  
     }
 61  
 
 62  
     /**
 63  
      * {@inheritDoc}
 64  
      */
 65  
     public Chunk read(final GUID guid, final InputStream stream, final long chunkStart) throws IOException
 66  
     {
 67  55
         BigInteger chunkLen = Utils.readBig64(stream);
 68  
         // Skip client GUID.
 69  55
         stream.skip(16);
 70  55
         BigInteger fileSize = Utils.readBig64(stream);
 71  
         // fileTime in 100 ns since midnight of 1st january 1601 GMT
 72  55
         BigInteger fileTime = Utils.readBig64(stream);
 73  
 
 74  55
         BigInteger packageCount = Utils.readBig64(stream);
 75  
 
 76  55
         BigInteger timeEndPos = Utils.readBig64(stream);
 77  55
         BigInteger duration = Utils.readBig64(stream);
 78  55
         BigInteger timeStartPos = Utils.readBig64(stream);
 79  
 
 80  55
         long flags = Utils.readUINT32(stream);
 81  
 
 82  55
         long minPkgSize = Utils.readUINT32(stream);
 83  55
         long maxPkgSize = Utils.readUINT32(stream);
 84  55
         long uncompressedFrameSize = Utils.readUINT32(stream);
 85  
 
 86  55
         final FileHeader result = new FileHeader(chunkLen, fileSize, fileTime, packageCount, duration, timeStartPos, timeEndPos, flags, minPkgSize, maxPkgSize, uncompressedFrameSize);
 87  55
         result.setPosition(chunkStart);
 88  55
         return result;
 89  
     }
 90  
 
 91  
 }