Coverage Report - org.jaudiotagger.tag.id3.framebody.FrameBodyENCR
 
Classes in this File Line Coverage Branch Coverage Complexity
FrameBodyENCR
0%
0/22
N/A
1
 
 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.ByteArraySizeTerminated;
 20  
 import org.jaudiotagger.tag.datatype.DataTypes;
 21  
 import org.jaudiotagger.tag.datatype.NumberFixedLength;
 22  
 import org.jaudiotagger.tag.datatype.StringNullTerminated;
 23  
 import org.jaudiotagger.tag.id3.ID3v24Frames;
 24  
 
 25  
 import java.nio.ByteBuffer;
 26  
 
 27  
 /**
 28  
  * Encryption method registration frame.
 29  
  * <p/>
 30  
  * <p/>
 31  
  * To identify with which method a frame has been encrypted the
 32  
  * encryption method must be registered in the tag with this frame. The
 33  
  * 'Owner identifier' is a null-terminated string with a URL
 34  
  * containing an email address, or a link to a location where an email
 35  
  * address can be found, that belongs to the organisation responsible
 36  
  * for this specific encryption method. Questions regarding the
 37  
  * encryption method should be sent to the indicated email address. The
 38  
  * 'Method symbol' contains a value that is associated with this method
 39  
  * throughout the whole tag. Values below $80 are reserved. The 'Method
 40  
  * symbol' may optionally be followed by encryption specific data. There
 41  
  * may be several "ENCR" frames in a tag but only one containing the
 42  
  * same symbol and only one containing the same owner identifier. The
 43  
  * method must be used somewhere in the tag. See section 3.3.1, flag j
 44  
  * for more information.
 45  
  * </p><p><table border=0 width="70%">
 46  
  * <tr><td colspan=2>&lt;Header for 'Encryption method registration', ID: "ENCR"&gt;</td></tr>
 47  
  * <tr><td>Owner identifier</td><td width="80%">&lt;text string&gt; $00</td></tr>
 48  
  * <tr><td>Method symbol   </td><td>$xx                           </td></tr>
 49  
  * <tr><td>Encryption data </td><td>&lt;binary data&gt;           </td></tr>
 50  
  * </table></p>
 51  
  * <p/>
 52  
  * <p>For more details, please refer to the ID3 specifications:
 53  
  * <ul>
 54  
  * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
 55  
  * </ul>
 56  
  *
 57  
  * @author : Paul Taylor
 58  
  * @author : Eric Farng
 59  
  * @version $Id: FrameBodyENCR.java,v 1.14 2008/07/21 10:45:42 paultaylor Exp $
 60  
  */
 61  
 public class FrameBodyENCR extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody
 62  
 {
 63  
     /**
 64  
      * Creates a new FrameBodyENCR datatype.
 65  
      */
 66  
     public FrameBodyENCR()
 67  0
     {
 68  0
         this.setObjectValue(DataTypes.OBJ_OWNER, "");
 69  0
         this.setObjectValue(DataTypes.OBJ_METHOD_SYMBOL, (byte) 0);
 70  0
         this.setObjectValue(DataTypes.OBJ_METHOD_SYMBOL, new byte[0]);
 71  0
     }
 72  
 
 73  
     public FrameBodyENCR(FrameBodyENCR body)
 74  
     {
 75  0
         super(body);
 76  0
     }
 77  
 
 78  
     /**
 79  
      * Creates a new FrameBodyENCR datatype.
 80  
      *
 81  
      * @param owner
 82  
      * @param methodSymbol
 83  
      * @param data
 84  
      */
 85  
     public FrameBodyENCR(String owner, byte methodSymbol, byte[] data)
 86  0
     {
 87  0
         this.setObjectValue(DataTypes.OBJ_OWNER, owner);
 88  0
         this.setObjectValue(DataTypes.OBJ_METHOD_SYMBOL, methodSymbol);
 89  0
         this.setObjectValue(DataTypes.OBJ_METHOD_SYMBOL, data);
 90  0
     }
 91  
 
 92  
     /**
 93  
      * Creates a new FrameBodyENCR datatype.
 94  
      *
 95  
      * @throws InvalidTagException if unable to create framebody from buffer
 96  
      */
 97  
     public FrameBodyENCR(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException
 98  
     {
 99  0
         super(byteBuffer, frameSize);
 100  0
     }
 101  
 
 102  
     /**
 103  
      * The ID3v2 frame identifier
 104  
      *
 105  
      * @return the ID3v2 frame identifier  for this frame type
 106  
      */
 107  
     public String getIdentifier()
 108  
     {
 109  0
         return ID3v24Frames.FRAME_ID_ENCRYPTION;
 110  
     }
 111  
 
 112  
     /**
 113  
      * @param owner
 114  
      */
 115  
     public void setOwner(String owner)
 116  
     {
 117  0
         setObjectValue(DataTypes.OBJ_OWNER, owner);
 118  0
     }
 119  
 
 120  
     /**
 121  
      * @return
 122  
      */
 123  
     public String getOwner()
 124  
     {
 125  0
         return (String) getObjectValue(DataTypes.OBJ_OWNER);
 126  
     }
 127  
 
 128  
     /**
 129  
      *
 130  
      */
 131  
     protected void setupObjectList()
 132  
     {
 133  0
         objectList.add(new StringNullTerminated(DataTypes.OBJ_OWNER, this));
 134  0
         objectList.add(new NumberFixedLength(DataTypes.OBJ_METHOD_SYMBOL, this, 1));
 135  0
         objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_ENCRYPTION_INFO, this));
 136  0
     }
 137  
 }