/** * Reads the length for arrays, sets and dictionaries. * * @param objInfo Object information byte. * @param offset Offset in the byte array at which the object is located. * @return An array with the length two. First entry is the length, second entry the offset at which the content starts. */ private int[] readLengthAndOffset(int objInfo, int offset) { int lengthValue = objInfo; int offsetValue = 1; if (objInfo == 0xF) { int int_type = this.bytes[offset + 1]; int intType = (int_type & 0xF0) >> 4; if (intType != 0x1) { System.err.println("BinaryPropertyListParser: Length integer has an unexpected type" + intType + ". Attempting to parse anyway..."); } int intInfo = int_type & 0x0F; int intLength = (int) Math.pow(2, intInfo); offsetValue = 2 + intLength; if (intLength < 3) { lengthValue = (int) parseUnsignedInt(this.bytes, offset + 2, offset + 2 + intLength); } else { lengthValue = new BigInteger(copyOfRange(this.bytes, offset + 2, offset + 2 + intLength)).intValue(); } } return new int[]{lengthValue, offsetValue}; }
String magic = new String(copyOfRange(this.bytes, 0, 8)); if (!magic.startsWith("bplist")) { throw new IllegalArgumentException("The given data is no binary property list. Wrong magic bytes: " + magic); byte[] trailer = copyOfRange(this.bytes, this.bytes.length - 32, this.bytes.length);
int length = lengthAndOffset[0]; int dataOffset = lengthAndOffset[1]; return new NSData(copyOfRange(this.bytes, offset + dataOffset, offset + dataOffset + length)); return new UID(String.valueOf(obj), copyOfRange(this.bytes, offset + 1, offset + 1 + length));