1 | package org.farng.mp3.id3; |
2 | |
3 | import org.farng.mp3.InvalidTagException; |
4 | import org.farng.mp3.object.ObjectNumberHashMap; |
5 | import org.farng.mp3.object.ObjectStringNullTerminated; |
6 | import org.farng.mp3.object.ObjectStringSizeTerminated; |
7 | |
8 | import java.io.IOException; |
9 | import java.io.RandomAccessFile; |
10 | |
11 | /** |
12 | * <p> This frame is intended for URL [URL] links concerning the audio file<br> in a similar |
13 | * way to the other "W"-frames. The frame body consists<br> |
14 | * <p/> |
15 | * of a description of the string, represented as a terminated string,<br> followed by the |
16 | * actual URL. The URL is always encoded with ISO-8859-1<br> [ISO-8859-1]. There may be more than one |
17 | * "WXXX" frame in each tag,<br> but only one with the same description.</p> |
18 | * <p/> |
19 | * <p> <Header for 'User defined URL link frame', ID: "WXXX"><br> |
20 | * Text encoding $xx<br> |
21 | * Description <text string according to encoding> $00 (00)<br> |
22 | * <p/> |
23 | * URL |
24 | * <text string><br> </p> |
25 | * |
26 | * @author Eric Farng |
27 | * @version $Revision: 1.4 $ |
28 | */ |
29 | public class FrameBodyWXXX extends AbstractID3v2FrameBody { |
30 | |
31 | String description = ""; |
32 | String urlLink = ""; |
33 | byte textEncoding = 0; |
34 | |
35 | /** |
36 | * Creates a new FrameBodyWXXX object. |
37 | */ |
38 | public FrameBodyWXXX() { |
39 | super(); |
40 | } |
41 | |
42 | /** |
43 | * Creates a new FrameBodyWXXX object. |
44 | */ |
45 | public FrameBodyWXXX(final FrameBodyWXXX body) { |
46 | super(body); |
47 | } |
48 | |
49 | /** |
50 | * Creates a new FrameBodyWXXX object. |
51 | */ |
52 | public FrameBodyWXXX(final byte textEncoding, final String description, final String urlLink) { |
53 | setObject("Text Encoding", new Byte(textEncoding)); |
54 | setObject("Description", description); |
55 | setObject("URL", urlLink); |
56 | } |
57 | |
58 | /** |
59 | * Creates a new FrameBodyWXXX object. |
60 | */ |
61 | public FrameBodyWXXX(final RandomAccessFile file) throws IOException, InvalidTagException { |
62 | this.read(file); |
63 | } |
64 | |
65 | public String getBriefDescription() { |
66 | return this.getUrlLink(); |
67 | } |
68 | |
69 | public String getIdentifier() { |
70 | return "WXXX" + ((char) 0) + this.description; |
71 | } |
72 | |
73 | public void setUrlLink(final String urlLink) { |
74 | setObject("URL", urlLink); |
75 | } |
76 | |
77 | public String getUrlLink() { |
78 | return (String) getObject("URL"); |
79 | } |
80 | |
81 | public boolean equals(final Object obj) { |
82 | if ((obj instanceof FrameBodyWXXX) == false) { |
83 | return false; |
84 | } |
85 | final FrameBodyWXXX frameBodyWXXX = (FrameBodyWXXX) obj; |
86 | if (this.description.equals(frameBodyWXXX.description) == false) { |
87 | return false; |
88 | } |
89 | if (this.textEncoding != frameBodyWXXX.textEncoding) { |
90 | return false; |
91 | } |
92 | if (this.urlLink.equals(frameBodyWXXX.urlLink) == false) { |
93 | return false; |
94 | } |
95 | return super.equals(obj); |
96 | } |
97 | |
98 | protected void setupObjectList() { |
99 | appendToObjectList(new ObjectNumberHashMap("Text Encoding", 1)); |
100 | appendToObjectList(new ObjectStringNullTerminated("Description")); |
101 | appendToObjectList(new ObjectStringSizeTerminated("URL")); |
102 | } |
103 | } |