/** * Convert the MVD file format data into an MVD object * * @param bytes a byte array of the decompressed file contents * @return a finished MVD * @throws and exception if it is not a valid MVD */ private static MVD parse(byte[] bytes) throws Exception { MVD mvd = null; // point after magic int p = MVD_MAGIC.length; // mask type - redundant int maskType = readInt(bytes, p); p += 4; int groupTableOffset = readInt(bytes, p); p += 4; int versionTableOffset = readInt(bytes, p); p += 4; int pairsTableOffset = readInt(bytes, p); p += 4; int dataTableOffset = readInt(bytes, p); p += 4; short strLen = readShort(bytes, p); String description = readUtf8String(bytes, p); p += strLen + 2; strLen = readShort(bytes, p); String encoding = readUtf8String(bytes, p); mvd = new MVD(description, encoding); // mvd.setMask( Mask.values()[maskType] ); p = groupTableOffset; readGroupTable(bytes, p, mvd); p = versionTableOffset; readVersionTable(bytes, p, mvd); p = pairsTableOffset; readPairsTable(bytes, p, dataTableOffset, mvd); int i = 0; try { for (i = 0; i < mvd.pairs.size(); i++) { Pair z = mvd.pairs.get(i); z.verify(); } } catch (Exception e) { System.out.println("Index:" + i + " " + e.getMessage()); } return mvd; }