| 1 | package org.farng.mp3.id3; |
| 2 | |
| 3 | import org.farng.mp3.InvalidTagException; |
| 4 | import org.farng.mp3.object.ObjectByteArraySizeTerminated; |
| 5 | import org.farng.mp3.object.ObjectStringNullTerminated; |
| 6 | |
| 7 | import java.io.IOException; |
| 8 | import java.io.RandomAccessFile; |
| 9 | |
| 10 | /** |
| 11 | * <h3>4.27. Private frame</h3> |
| 12 | * <p/> |
| 13 | * <p> This frame is used to contain information from a software producer<br> that its program |
| 14 | * uses and does not fit into the other frames. The<br> frame consists of an 'Owner identifier' string and |
| 15 | * the binary data.<br> The 'Owner identifier' is a null-terminated string with a URL [URL]<br> |
| 16 | * containing an email address, or a link to a location where an email<br> |
| 17 | * <p/> |
| 18 | * address can be found, that belongs to the organisation responsible<br> for the frame. |
| 19 | * Questions regarding the frame should be sent to the<br> indicated email address. The tag may contain |
| 20 | * more than one "PRIV"<br> frame but only with different contents.</p> |
| 21 | * <p/> |
| 22 | * <p> <Header for 'Private frame', ID: "PRIV"><br> |
| 23 | * Owner identifier <text string> $00<br> The private |
| 24 | * data |
| 25 | * <p/> |
| 26 | * <binary data><br> </p> |
| 27 | * |
| 28 | * @author Eric Farng |
| 29 | * @version $Revision: 1.4 $ |
| 30 | */ |
| 31 | public class FrameBodyPRIV extends AbstractID3v2FrameBody { |
| 32 | |
| 33 | /** |
| 34 | * Creates a new FrameBodyPRIV object. |
| 35 | */ |
| 36 | public FrameBodyPRIV() { |
| 37 | super(); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Creates a new FrameBodyPRIV object. |
| 42 | */ |
| 43 | public FrameBodyPRIV(final FrameBodyPRIV body) { |
| 44 | super(body); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Creates a new FrameBodyPRIV object. |
| 49 | */ |
| 50 | public FrameBodyPRIV(final String owner, final byte[] data) { |
| 51 | setObject("Owner", owner); |
| 52 | setObject("Private Data", data); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Creates a new FrameBodyPRIV object. |
| 57 | */ |
| 58 | public FrameBodyPRIV(final RandomAccessFile file) throws IOException, InvalidTagException { |
| 59 | this.read(file); |
| 60 | } |
| 61 | |
| 62 | public String getBriefDescription() { |
| 63 | return this.getOwner(); |
| 64 | } |
| 65 | |
| 66 | public void setData(final byte[] data) { |
| 67 | setObject("Private Data", data); |
| 68 | } |
| 69 | |
| 70 | public byte[] getData() { |
| 71 | return (byte[]) getObject("Private Data"); |
| 72 | } |
| 73 | |
| 74 | public String getIdentifier() { |
| 75 | return "PRIV" + ((char) 0) + getOwner() + ((char) 0) + (new String(getData())); |
| 76 | } |
| 77 | |
| 78 | public void setOwner(final String owner) { |
| 79 | setObject("Owner", owner); |
| 80 | } |
| 81 | |
| 82 | public String getOwner() { |
| 83 | return (String) getObject("Owner"); |
| 84 | } |
| 85 | |
| 86 | protected void setupObjectList() { |
| 87 | appendToObjectList(new ObjectStringNullTerminated("Owner")); |
| 88 | appendToObjectList(new ObjectByteArraySizeTerminated("Private Data")); |
| 89 | } |
| 90 | } |