1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package entagged.audioformats.ape.util;
20
21 import java.io.UnsupportedEncodingException;
22
23 import entagged.audioformats.generic.TagField;
24
25 public abstract class ApeTagField implements TagField {
26
27 private String id;
28 private boolean binary;
29
30 public ApeTagField(String id, boolean binary) {
31 this.id = id;
32 this.binary = binary;
33 }
34
35 public String getId() {
36 return this.id;
37 }
38
39 public boolean isBinary() {
40 return binary;
41 }
42
43 public void isBinary(boolean b) {
44 this.binary = b;
45 }
46
47 public boolean isCommon() {
48 return id.equals("Title") ||
49 id.equals("Album") ||
50 id.equals("Artist") ||
51 id.equals("Genre") ||
52 id.equals("Track") ||
53 id.equals("Year") ||
54 id.equals("Comment");
55 }
56
57 protected void copy(byte[] src, byte[] dst, int dstOffset) {
58 for(int i = 0; i<src.length; i++)
59 dst[i+dstOffset] = src[i];
60 }
61
62 protected byte[] getSize(int size) {
63 byte[] b = new byte[4];
64 b[3] = (byte) ( ( size & 0xFF000000 ) >> 24 );
65 b[2] = (byte) ( ( size & 0x00FF0000 ) >> 16 );
66 b[1] = (byte) ( ( size & 0x0000FF00 ) >> 8 );
67 b[0] = (byte) ( size & 0x000000FF );
68 return b;
69 }
70
71 protected byte[] getBytes(String s, String encoding) throws UnsupportedEncodingException{
72 return s.getBytes(encoding);
73 }
74
75 public abstract boolean isEmpty();
76 public abstract String toString();
77 public abstract void copyContent(TagField field);
78 public abstract byte[] getRawContent() throws UnsupportedEncodingException;
79 }