1 package org.catacomb.serial.jar;
2
3
4
5 public class CustomJar {
6
7
8 private final static byte[] MAGIC_SDJ = {(byte)0x45, (byte)0x53, (byte)0x44, (byte)0x41};
9
10 private final static byte[] MAGIC_ZIP = {(byte)0x50, (byte)0x4b, (byte)0x03, (byte)0x04};
11
12 private final static String MAIN = "mainname";
13 private final static String MIME = "mimetype";
14
15
16
17
18 public static boolean isMetaName(String s) {
19 return (s != null && (s.equals(MAIN) || s.equals(MIME)));
20 }
21
22 public static String getMetaMain() {
23 return MAIN;
24 }
25
26
27 public static String getMetaMime() {
28 return MIME;
29 }
30
31
32
33 public static boolean claims(byte[] ba) {
34 return (claims(ba, MAGIC_SDJ) || claims(ba, MAGIC_ZIP));
35 }
36
37
38 public static boolean claims(byte[] ba, byte[] magic) {
39 boolean matches = true;
40 for (int i = 0; i < 4; i++) {
41 if (ba[i] == magic[i]) {
42
43 } else {
44 matches = false;
45 }
46 }
47 return matches;
48 }
49
50
51
52 public static void naturalize(byte[] ba) {
53 for (int i = 0; i < 4; i++) {
54 ba[i] = MAGIC_ZIP[i];
55 }
56 }
57
58
59 }