-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractID3v2FrameData.java
More file actions
59 lines (48 loc) · 1.48 KB
/
Copy pathAbstractID3v2FrameData.java
File metadata and controls
59 lines (48 loc) · 1.48 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
package Mp3File;
public abstract class AbstractID3v2FrameData {
boolean unsynchronisation;
public AbstractID3v2FrameData(boolean unsynchronisation) {
this.unsynchronisation = unsynchronisation;
}
protected final void synchroniseAndUnpackFrameData(byte[] bytes) throws InvalidDataException {
if (unsynchronisation && BufferTools.sizeSynchronisationWouldSubtract(bytes) > 0) {
byte[] synchronisedBytes = BufferTools.synchroniseBuffer(bytes);
unpackFrameData(synchronisedBytes);
} else {
unpackFrameData(bytes);
}
}
protected byte[] packAndUnsynchroniseFrameData() {
byte[] bytes = packFrameData();
if (unsynchronisation && BufferTools.sizeUnsynchronisationWouldAdd(bytes) > 0) {
return BufferTools.unsynchroniseBuffer(bytes);
}
return bytes;
}
protected byte[] toBytes() {
return packAndUnsynchroniseFrameData();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (unsynchronisation ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractID3v2FrameData other = (AbstractID3v2FrameData) obj;
if (unsynchronisation != other.unsynchronisation)
return false;
return true;
}
protected abstract void unpackFrameData(byte[] bytes) throws InvalidDataException;
protected abstract byte[] packFrameData();
protected abstract int getLength();
}