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.ObjectStringHashMap; |
6 | import org.farng.mp3.object.ObjectStringSizeTerminated; |
7 | |
8 | import java.io.IOException; |
9 | import java.io.RandomAccessFile; |
10 | |
11 | /** |
12 | * <h3>4.22. Terms of use frame</h3> |
13 | * <p/> |
14 | * <p> This frame contains a brief description of the terms of use and<br> ownership of the |
15 | * file. More detailed information concerning the legal<br> terms might be available through the |
16 | * "WCOP" frame. Newlines are<br> allowed in the text. There may be more than one 'Terms of use' |
17 | * frame<br> |
18 | * <p/> |
19 | * in a tag, but only one with the same 'Language'.</p> |
20 | * <p/> |
21 | * <p> <Header for 'Terms of use frame', ID: "USER"><br> |
22 | * Text encoding $xx<br> |
23 | * <p/> |
24 | * Language $xx xx xx<br> |
25 | * The actual text <text string according to encoding><br> |
26 | * </p> |
27 | * |
28 | * @author Eric Farng |
29 | * @version $Revision: 1.4 $ |
30 | */ |
31 | public class FrameBodyUSER extends AbstractID3v2FrameBody { |
32 | |
33 | /** |
34 | * Creates a new FrameBodyUSER object. |
35 | */ |
36 | public FrameBodyUSER() { |
37 | super(); |
38 | } |
39 | |
40 | /** |
41 | * Creates a new FrameBodyUSER object. |
42 | */ |
43 | public FrameBodyUSER(final FrameBodyUSER body) { |
44 | super(body); |
45 | } |
46 | |
47 | /** |
48 | * Creates a new FrameBodyUSER object. |
49 | */ |
50 | public FrameBodyUSER(final byte textEncoding, final String language, final String text) { |
51 | setObject("Text Encoding", new Byte(textEncoding)); |
52 | setObject("Language", language); |
53 | setObject("Text", text); |
54 | } |
55 | |
56 | /** |
57 | * Creates a new FrameBodyUSER object. |
58 | */ |
59 | public FrameBodyUSER(final RandomAccessFile file) throws IOException, InvalidTagException { |
60 | this.read(file); |
61 | } |
62 | |
63 | public String getIdentifier() { |
64 | return "USER" + ((char) 0) + getLanguage(); |
65 | } |
66 | |
67 | public String getLanguage() { |
68 | return (String) getObject(ObjectStringHashMap.LANGUAGE); |
69 | } |
70 | |
71 | public void setOwner(final String language) { |
72 | setObject(ObjectStringHashMap.LANGUAGE, language); |
73 | } |
74 | |
75 | protected void setupObjectList() { |
76 | appendToObjectList(new ObjectNumberHashMap(ObjectNumberHashMap.TEXT_ENCODING, 1)); |
77 | appendToObjectList(new ObjectStringHashMap(ObjectStringHashMap.LANGUAGE, 3)); |
78 | appendToObjectList(new ObjectStringSizeTerminated("Text")); |
79 | } |
80 | } |