-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathID3v2TextFrameData.java
More file actions
78 lines (66 loc) · 1.79 KB
/
Copy pathID3v2TextFrameData.java
File metadata and controls
78 lines (66 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package Mp3File;
public class ID3v2TextFrameData extends AbstractID3v2FrameData {
protected EncodedText text;
public ID3v2TextFrameData(boolean unsynchronisation) {
super(unsynchronisation);
}
public ID3v2TextFrameData(boolean unsynchronisation, EncodedText text) {
super(unsynchronisation);
this.text = text;
}
public ID3v2TextFrameData(boolean unsynchronisation, byte[] bytes) throws InvalidDataException {
super(unsynchronisation);
synchroniseAndUnpackFrameData(bytes);
}
@Override
protected void unpackFrameData(byte[] bytes) throws InvalidDataException {
text = new EncodedText(bytes[0], BufferTools.copyBuffer(bytes, 1, bytes.length - 1));
}
@Override
protected byte[] packFrameData() {
byte[] bytes = new byte[getLength()];
if (text != null) {
bytes[0] = text.getTextEncoding();
byte[] textBytes = text.toBytes(true, false);
if (textBytes.length > 0) {
BufferTools.copyIntoByteBuffer(textBytes, 0, textBytes.length, bytes, 1);
}
}
return bytes;
}
@Override
protected int getLength() {
int length = 1;
if (text != null) length += text.toBytes(true, false).length;
return length;
}
public EncodedText getText() {
return text;
}
public void setText(EncodedText text) {
this.text = text;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((text == null) ? 0 : text.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
ID3v2TextFrameData other = (ID3v2TextFrameData) obj;
if (text == null) {
if (other.text != null)
return false;
} else if (!text.equals(other.text))
return false;
return true;
}
}