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.ObjectNumberFixedLength; |
6 | import org.farng.mp3.object.ObjectStringNullTerminated; |
7 | |
8 | import java.io.IOException; |
9 | import java.io.RandomAccessFile; |
10 | |
11 | /** |
12 | * <h3>4.26. Group identification registration</h3> |
13 | * <p/> |
14 | * <p> This frame enables grouping of otherwise unrelated frames. This can<br> |
15 | * <p/> |
16 | * be used when some frames are to be signed. To identify which frames<br> belongs to a set of |
17 | * frames a group identifier must be registered in<br> the tag with this frame. The 'Owner identifier' is a |
18 | * null-terminated<br> string with a URL [URL] containing an email address, or a link to a<br> |
19 | * location where an email address can be found, that belongs to the<br> |
20 | * <p/> |
21 | * organisation responsible for this grouping. Questions regarding the<br> grouping should be |
22 | * sent to the indicated email address. The 'Group<br> symbol' contains a value that associates the frame |
23 | * with this group<br> throughout the whole tag, in the range $80-F0. All other values are<br> |
24 | * reserved. The 'Group symbol' may optionally be followed by some group<br> |
25 | * <p/> |
26 | * specific data, e.g. a digital signature. There may be several "GRID"<br> frames |
27 | * in a tag but only one containing the same symbol and only one<br> containing the same owner identifier. |
28 | * The group symbol must be used<br> somewhere in the tag. See the description of the frame grouping |
29 | * flag<br> |
30 | * <p/> |
31 | * in the ID3v2 structure document [ID3v2-strct] for more information.</p> |
32 | * <p/> |
33 | * <p> <Header for 'Group ID registration', ID: "GRID"><br> |
34 | * Owner identifier <text string> $00<br> |
35 | * <p/> |
36 | * Group symbol $xx<br> |
37 | * Group dependent data <binary data><br> </p> |
38 | * |
39 | * @author Eric Farng |
40 | * @version $Revision: 1.4 $ |
41 | */ |
42 | public class FrameBodyGRID extends AbstractID3v2FrameBody { |
43 | |
44 | /** |
45 | * Creates a new FrameBodyGRID object. |
46 | */ |
47 | public FrameBodyGRID() { |
48 | super(); |
49 | } |
50 | |
51 | /** |
52 | * Creates a new FrameBodyGRID object. |
53 | */ |
54 | public FrameBodyGRID(final FrameBodyGRID body) { |
55 | super(body); |
56 | } |
57 | |
58 | /** |
59 | * Creates a new FrameBodyGRID object. |
60 | */ |
61 | public FrameBodyGRID(final String owner, final byte groupSymbol, final byte[] data) { |
62 | setObject("Owner", owner); |
63 | setObject("Group Symbol", new Byte(groupSymbol)); |
64 | setObject("Group Dependent Data", data); |
65 | } |
66 | |
67 | /** |
68 | * Creates a new FrameBodyGRID object. |
69 | */ |
70 | public FrameBodyGRID(final RandomAccessFile file) throws IOException, InvalidTagException { |
71 | this.read(file); |
72 | } |
73 | |
74 | public void setGroupSymbol(final byte textEncoding) { |
75 | setObject("Group Symbol", new Byte(textEncoding)); |
76 | } |
77 | |
78 | public byte getGroupSymbol() { |
79 | if (getObject("Group Symbol") != null) { |
80 | return ((Byte) getObject("Group Symbol")).byteValue(); |
81 | } |
82 | return 0; |
83 | } |
84 | |
85 | public String getIdentifier() { |
86 | return "GRID" + ((char) 0) + getOwner() + ((char) 0) + getGroupSymbol(); |
87 | } |
88 | |
89 | public void setOwner(final String owner) { |
90 | setObject("Owner", owner); |
91 | } |
92 | |
93 | public String getOwner() { |
94 | return (String) getObject("Owner"); |
95 | } |
96 | |
97 | protected void setupObjectList() { |
98 | appendToObjectList(new ObjectStringNullTerminated("Owner")); |
99 | appendToObjectList(new ObjectNumberFixedLength("Group Symbol", 1)); |
100 | appendToObjectList(new ObjectByteArraySizeTerminated("Group Dependent Data")); |
101 | } |
102 | } |