| 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.1. Unique file identifier</h3> |
| 12 | * <p/> |
| 13 | * <p> This frame's purpose is to be able to identify the audio file in a<br> database, that |
| 14 | * may provide more information relevant to the content.<br> Since standardisation of such a database is |
| 15 | * beyond this document, all<br> |
| 16 | * <p/> |
| 17 | * UFID frames begin with an 'owner identifier' field. It is a null-<br> terminated string |
| 18 | * with a URL [URL] containing an email address, or a<br> link to a location where an email address can be |
| 19 | * found, that belongs<br> to the organisation responsible for this specific database<br> |
| 20 | * implementation. Questions regarding the database should be sent to<br> |
| 21 | * <p/> |
| 22 | * the indicated email address. The URL should not be used for the<br> actual database |
| 23 | * queries. The string<br> "http://www.id3.org/dummy/ufid.html" should be used for tests. The<br> |
| 24 | * 'Owner identifier' must be non-empty (more than just a termination).<br> |
| 25 | * <p/> |
| 26 | * The 'Owner identifier' is then followed by the actual identifier,<br> which may be up to 64 |
| 27 | * bytes. There may be more than one "UFID" frame<br> in a tag, but only one with the same 'Owner |
| 28 | * identifier'.</p> |
| 29 | * <p/> |
| 30 | * <p> <Header for 'Unique file identifier', ID: "UFID"><br> |
| 31 | * Owner identifier <text string> $00<br> |
| 32 | * Identifier |
| 33 | * <p/> |
| 34 | * <up to 64 bytes binary data><br> </p> |
| 35 | * |
| 36 | * @author Eric Farng |
| 37 | * @version $Revision: 1.4 $ |
| 38 | */ |
| 39 | public class FrameBodyUFID extends AbstractID3v2FrameBody { |
| 40 | |
| 41 | /** |
| 42 | * Creates a new FrameBodyUFID object. |
| 43 | */ |
| 44 | public FrameBodyUFID() { |
| 45 | super(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Creates a new FrameBodyUFID object. |
| 50 | */ |
| 51 | public FrameBodyUFID(final FrameBodyUFID body) { |
| 52 | super(body); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Creates a new FrameBodyUFID object. |
| 57 | */ |
| 58 | public FrameBodyUFID(final String owner, final byte[] identifier) { |
| 59 | setObject("Owner", owner); |
| 60 | setObject("Identifier", identifier); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Creates a new FrameBodyUFID object. |
| 65 | */ |
| 66 | public FrameBodyUFID(final RandomAccessFile file) throws IOException, InvalidTagException { |
| 67 | this.read(file); |
| 68 | } |
| 69 | |
| 70 | public String getIdentifier() { |
| 71 | return "UFID" + ((char) 0) + getOwner(); |
| 72 | } |
| 73 | |
| 74 | public void setOwner(final String owner) { |
| 75 | setObject("Owner", owner); |
| 76 | } |
| 77 | |
| 78 | public String getOwner() { |
| 79 | return (String) getObject("Owner"); |
| 80 | } |
| 81 | |
| 82 | protected void setupObjectList() { |
| 83 | appendToObjectList(new ObjectStringNullTerminated("Owner")); |
| 84 | appendToObjectList(new ObjectByteArraySizeTerminated("Identifier")); |
| 85 | } |
| 86 | } |