Class BinaryPropertyListParser

java.lang.Object
com.dd.plist.BinaryPropertyListParser

public final class BinaryPropertyListParser extends Object
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 Type
    Method
    Description
    static byte[]
    copyOfRange(byte[] src, int startIndex, int endIndex)
    Copies a part of a byte array into a new array.
    static NSObject
    parse(byte[] data)
    Parses a binary property list from a byte array.
    static NSObject
    Parses a binary property list file.
    static NSObject
    Parses a binary property list from an input stream.
    static NSObject
    parse(Path path)
    Parses a binary property list file.
    static double
    parseDouble(byte[] bytes)
    Parses a double from a (big-endian) byte array.
    static double
    parseDouble(byte[] bytes, int startIndex, int endIndex)
    Parses a double from a (big-endian) byte array.
    static long
    parseLong(byte[] bytes)
    Parses a long from a (big-endian) byte array.
    static long
    parseLong(byte[] bytes, int startIndex, int endIndex)
    Parses a long from a (big-endian) byte array.
    static long
    parseUnsignedInt(byte[] bytes)
    Parses an unsigned integers from a byte array.
    static long
    parseUnsignedInt(byte[] bytes, int startIndex, int endIndex)
    Parses an unsigned integer from a byte array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • parse

      public static NSObject parse(File f) throws IOException, PropertyListFormatException
      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 NSDictionary but can also be a NSArray.
      Throws:
      PropertyListFormatException - When the property list's format could not be parsed.
      IOException - If a NSString object could not be decoded or an I/O error occurs on the input stream.
    • parse

      public static NSObject parse(Path path) throws IOException, PropertyListFormatException
      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 NSDictionary but can also be a NSArray.
      Throws:
      PropertyListFormatException - When the property list's format could not be parsed.
      IOException - If a NSString object could not be decoded or an I/O error occurs on the input stream.
    • parse

      public static NSObject parse(InputStream is) throws IOException, PropertyListFormatException
      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 NSDictionary but can also be a NSArray.
      Throws:
      PropertyListFormatException - When the property list's format could not be parsed.
      IOException - If a NSString object 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 NSDictionary but can also be a NSArray.
      Throws:
      PropertyListFormatException - When the property list's format could not be parsed.
      UnsupportedEncodingException - If a NSString object 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.