Coverage Report - org.jaudiotagger.tag.id3.framebody.FrameBodyGEOB
 
Classes in this File Line Coverage Branch Coverage Complexity
FrameBodyGEOB
0%
0/34
0%
0/4
1.222
 
 1  
 /*
 2  
  *  MusicTag Copyright (C)2003,2004
 3  
  *
 4  
  *  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
 5  
  *  General Public  License as published by the Free Software Foundation; either version 2.1 of the License,
 6  
  *  or (at your option) any later version.
 7  
  *
 8  
  *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 9  
  *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 10  
  *  See the GNU Lesser General Public License for more details.
 11  
  *
 12  
  *  You should have received a copy of the GNU Lesser General Public License along with this library; if not,
 13  
  *  you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
 14  
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 15  
  */
 16  
 package org.jaudiotagger.tag.id3.framebody;
 17  
 
 18  
 import org.jaudiotagger.tag.InvalidTagException;
 19  
 import org.jaudiotagger.tag.datatype.*;
 20  
 import org.jaudiotagger.tag.id3.ID3v24Frames;
 21  
 import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
 22  
 
 23  
 import java.io.ByteArrayOutputStream;
 24  
 import java.nio.ByteBuffer;
 25  
 
 26  
 /**
 27  
  * General encapsulated object frame.
 28  
  * <p/>
 29  
  * <p/>
 30  
  * In this frame any type of file can be encapsulated. After the header,
 31  
  * 'Frame size' and 'Encoding' follows 'MIME type' represented as
 32  
  * as a terminated string encoded with ISO-8859-1. The
 33  
  * filename is case sensitive and is encoded as 'Encoding'. Then follows
 34  
  * a content description as terminated string, encoded as 'Encoding'.
 35  
  * The last thing in the frame is the actual object. The first two
 36  
  * strings may be omitted, leaving only their terminations. There may be more than one "GEOB"
 37  
  * frame in each tag, but only one with the same content descriptor.
 38  
  * </p><p><table border=0 width="70%">
 39  
  * <tr><td colspan=2> &lt;Header for 'General encapsulated object', ID: "GEOB"&gt;</td></tr>
 40  
  * <tr><td>Text encoding       </td><td>$xx                     </td></tr>
 41  
  * <tr><td>MIME type           </td><td>&lt;text string&gt; $00 </td></tr>
 42  
  * <tr><td>Filename            </td><td>&lt;text string according to encoding&gt; $00 (00)</td></tr>
 43  
  * <tr><td>Content description </td><td><text string according to enc�ding> $00 (00)</td></tr>
 44  
  * <tr><td>Encapsulated object </td><td>&lt;binary data&gt;     </td></tr>
 45  
  * </table></p>
 46  
  * <p/>
 47  
  * <p>For more details, please refer to the ID3 specifications:
 48  
  * <ul>
 49  
  * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
 50  
  * </ul>
 51  
  *
 52  
  * @author : Paul Taylor
 53  
  * @author : Eric Farng
 54  
  * @version $Id: FrameBodyGEOB.java,v 1.16 2008/07/21 10:45:42 paultaylor Exp $
 55  
  */
 56  
 public class FrameBodyGEOB extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody
 57  
 {
 58  
 
 59  
     /**
 60  
      * Creates a new FrameBodyGEOB datatype.
 61  
      */
 62  
     public FrameBodyGEOB()
 63  0
     {
 64  0
         this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
 65  0
         this.setObjectValue(DataTypes.OBJ_MIME_TYPE, "");
 66  0
         this.setObjectValue(DataTypes.OBJ_FILENAME, "");
 67  0
         this.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
 68  0
         this.setObjectValue(DataTypes.OBJ_DATA, new byte[0]);
 69  0
     }
 70  
 
 71  
     public FrameBodyGEOB(FrameBodyGEOB body)
 72  
     {
 73  0
         super(body);
 74  0
     }
 75  
 
 76  
     /**
 77  
      * Creates a new FrameBodyGEOB datatype.
 78  
      *
 79  
      * @param textEncoding
 80  
      * @param mimeType
 81  
      * @param filename
 82  
      * @param description
 83  
      * @param object
 84  
      */
 85  
     public FrameBodyGEOB(byte textEncoding, String mimeType, String filename, String description, byte[] object)
 86  0
     {
 87  0
         this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
 88  0
         this.setObjectValue(DataTypes.OBJ_MIME_TYPE, mimeType);
 89  0
         this.setObjectValue(DataTypes.OBJ_FILENAME, filename);
 90  0
         this.setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
 91  0
         this.setObjectValue(DataTypes.OBJ_DATA, object);
 92  0
     }
 93  
 
 94  
     /**
 95  
      * Creates a new FrameBodyGEOB datatype.
 96  
      *
 97  
      * @throws InvalidTagException if unable to create framebody from buffer
 98  
      */
 99  
     public FrameBodyGEOB(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException
 100  
     {
 101  0
         super(byteBuffer, frameSize);
 102  0
     }
 103  
 
 104  
     /**
 105  
      * @param description
 106  
      */
 107  
     public void setDescription(String description)
 108  
     {
 109  0
         setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
 110  0
     }
 111  
 
 112  
     /**
 113  
      * @return the description field
 114  
      */
 115  
     public String getDescription()
 116  
     {
 117  0
         return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION);
 118  
     }
 119  
 
 120  
     /**
 121  
      * @return
 122  
      */
 123  
     public String getIdentifier()
 124  
     {
 125  0
         return ID3v24Frames.FRAME_ID_GENERAL_ENCAPS_OBJECT;
 126  
     }
 127  
 
 128  
 
 129  
     /**
 130  
      * If the filename or description cannot be encoded using current encoder, change the encoder
 131  
      */
 132  
     public void write(ByteArrayOutputStream tagBuffer)
 133  
     {
 134  0
         if (((AbstractString) getObject(DataTypes.OBJ_FILENAME)).canBeEncoded() == false)
 135  
         {
 136  0
             this.setTextEncoding(TextEncoding.UTF_16);
 137  
         }
 138  0
         if (((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded() == false)
 139  
         {
 140  0
             this.setTextEncoding(TextEncoding.UTF_16);
 141  
         }
 142  0
         super.write(tagBuffer);
 143  0
     }
 144  
 
 145  
     /**
 146  
      *
 147  
      */
 148  
     protected void setupObjectList()
 149  
     {
 150  0
         objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
 151  0
         objectList.add(new StringNullTerminated(DataTypes.OBJ_MIME_TYPE, this));
 152  0
         objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_FILENAME, this));
 153  0
         objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_DESCRIPTION, this));
 154  0
         objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_DATA, this));
 155  0
     }
 156  
 }