Class BinaryPropertyListParser
java.lang.Object
com.dd.plist.BinaryPropertyListParser
Parses property lists that are in Apple's binary format.
Use this class when you are sure about the format of the property list.
Otherwise, use the PropertyListParser class.
Parsing is done by calling the static parse methods.
- Author:
- Daniel Dreibrodt
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]copyOfRange(byte[] src, int startIndex, int endIndex) Copies a part of a byte array into a new array.static NSObjectparse(byte[] data) Parses a binary property list from a byte array.static NSObjectParses a binary property list file.static NSObjectparse(InputStream is) Parses a binary property list from an input stream.static NSObjectParses a binary property list file.static doubleparseDouble(byte[] bytes) Parses a double from a (big-endian) byte array.static doubleparseDouble(byte[] bytes, int startIndex, int endIndex) Parses a double from a (big-endian) byte array.static longparseLong(byte[] bytes) Parses a long from a (big-endian) byte array.static longparseLong(byte[] bytes, int startIndex, int endIndex) Parses a long from a (big-endian) byte array.static longparseUnsignedInt(byte[] bytes) Parses an unsigned integers from a byte array.static longparseUnsignedInt(byte[] bytes, int startIndex, int endIndex) Parses an unsigned integer from a byte array.
-
Method Details
-
parse
Parses a binary property list file.- Parameters:
f- The binary property list file- Returns:
- The root object of the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
PropertyListFormatException- When the property list's format could not be parsed.IOException- If aNSStringobject could not be decoded or an I/O error occurs on the input stream.
-
parse
Parses a binary property list file.- Parameters:
path- The path to the binary property list file- Returns:
- The root object of the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
PropertyListFormatException- When the property list's format could not be parsed.IOException- If aNSStringobject could not be decoded or an I/O error occurs on the input stream.
-
parse
Parses a binary property list from an input stream. This method does not close the specified input stream.- Parameters:
is- The input stream that points to the property list's data.- Returns:
- The root object of the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
PropertyListFormatException- When the property list's format could not be parsed.IOException- If aNSStringobject could not be decoded or an I/O error occurs on the input stream.
-
parse
public static NSObject parse(byte[] data) throws PropertyListFormatException, UnsupportedEncodingException Parses a binary property list from a byte array.- Parameters:
data- The binary property list's data.- Returns:
- The root object of the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
PropertyListFormatException- When the property list's format could not be parsed.UnsupportedEncodingException- If aNSStringobject could not be decoded.
-
parseUnsignedInt
public static long parseUnsignedInt(byte[] bytes) Parses an unsigned integers from a byte array.- Parameters:
bytes- The byte array containing the unsigned integer.- Returns:
- The unsigned integer represented by the given bytes.
-
parseUnsignedInt
public static long parseUnsignedInt(byte[] bytes, int startIndex, int endIndex) Parses an unsigned integer from a byte array.- Parameters:
bytes- The byte array containing the unsigned integer.startIndex- Beginning of the unsigned int in the byte array.endIndex- End of the unsigned int in the byte array.- Returns:
- The unsigned integer represented by the given bytes.
-
parseLong
public static long parseLong(byte[] bytes) Parses a long from a (big-endian) byte array.- Parameters:
bytes- The bytes representing the long integer.- Returns:
- The long integer represented by the given bytes.
-
parseLong
public static long parseLong(byte[] bytes, int startIndex, int endIndex) Parses a long from a (big-endian) byte array.- Parameters:
bytes- The bytes representing the long integer.startIndex- Beginning of the long in the byte array.endIndex- End of the long in the byte array.- Returns:
- The long integer represented by the given bytes.
-
parseDouble
public static double parseDouble(byte[] bytes) Parses a double from a (big-endian) byte array.- Parameters:
bytes- The bytes representing the double.- Returns:
- The double represented by the given bytes.
-
parseDouble
public static double parseDouble(byte[] bytes, int startIndex, int endIndex) Parses a double from a (big-endian) byte array.- Parameters:
bytes- The bytes representing the double.startIndex- Beginning of the double in the byte array.endIndex- End of the double in the byte array.- Returns:
- The double represented by the given bytes.
-
copyOfRange
public static byte[] copyOfRange(byte[] src, int startIndex, int endIndex) Copies a part of a byte array into a new array.- Parameters:
src- The source array.startIndex- The index from which to start copying.endIndex- The index until which to copy.- Returns:
- The copied array.
-