Package com.dd.plist

Class BinaryPropertyListWriter


  • public final class BinaryPropertyListWriter
    extends java.lang.Object
    Writes property lists in the binary format.
    • Constructor Summary

      Constructors 
      Constructor Description
      BinaryPropertyListWriter​(java.io.OutputStream outStr, int version)
      Creates a new binary property list writer
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      (package private) void assignID​(NSObject obj)  
      private static int computeIdSizeInBytes​(int numberOfIds)  
      private int computeOffsetSizeInBytes​(long maxOffset)  
      (package private) int getID​(NSObject obj)  
      private static int getMinimumRequiredVersion​(NSObject root)
      Finds out the minimum binary property list format version that can be used to save the given NSObject tree.
      (package private) void write​(byte[] bytes)  
      (package private) void write​(int b)  
      (package private) void write​(NSObject root)  
      static void write​(NSObject root, java.io.File file)
      Writes a binary plist file with the given object as the root.
      static void write​(NSObject root, java.io.File file, boolean createParentDirectories)
      Writes a binary plist file with the given object as the root.
      static void write​(NSObject root, java.io.OutputStream out)
      Writes a binary plist serialization of the given object as the root.
      static void write​(NSObject root, java.nio.file.Path path)
      Writes a binary plist file with the given object as the root.
      static void write​(java.io.File file, NSObject root)
      Deprecated.
      Use the overload that takes the root as first argument and the file as second.
      static void write​(java.io.OutputStream out, NSObject root)
      Deprecated.
      Use the overload that takes the root as first argument and the stream as second.
      (package private) void writeBytes​(long value, int bytes)  
      (package private) void writeDouble​(double value)  
      (package private) void writeID​(int id)  
      (package private) void writeIntHeader​(int kind, int value)  
      (package private) void writeLong​(long value)  
      static byte[] writeToArray​(NSObject root)
      Writes a binary plist serialization of the given object as the root into a byte array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • version

        private int version
      • out

        private final java.io.OutputStream out
      • count

        private long count
      • idMap

        private final java.util.Map<NSObject,​java.lang.Integer> idMap
      • idSizeInBytes

        private int idSizeInBytes
    • Constructor Detail

      • BinaryPropertyListWriter

        BinaryPropertyListWriter​(java.io.OutputStream outStr,
                                 int version)
        Creates a new binary property list writer
        Parameters:
        outStr - The output stream into which the binary property list will be written
        version - The binary property list format version.
    • Method Detail

      • getMinimumRequiredVersion

        private static int getMinimumRequiredVersion​(NSObject root)
        Finds out the minimum binary property list format version that can be used to save the given NSObject tree.
        Parameters:
        root - Object root
        Returns:
        Version code
      • write

        @Deprecated
        public static void write​(java.io.File file,
                                 NSObject root)
                          throws java.io.IOException
        Deprecated.
        Use the overload that takes the root as first argument and the file as second.
        Writes a binary plist file with the given object as the root.
        Parameters:
        file - The file to write to.
        root - The source of the data to write to the file.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
      • write

        public static void write​(NSObject root,
                                 java.io.File file)
                          throws java.io.IOException
        Writes a binary plist file with the given object as the root.
        Parameters:
        root - The source of the data to write to the file.
        file - The file to write to.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
      • write

        public static void write​(NSObject root,
                                 java.io.File file,
                                 boolean createParentDirectories)
                          throws java.io.IOException
        Writes a binary plist file with the given object as the root.
        Parameters:
        root - The source of the data to write to the file.
        file - The file to write to.
        createParentDirectories - If set to true, the file's parent directories will be created.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
      • write

        public static void write​(NSObject root,
                                 java.nio.file.Path path)
                          throws java.io.IOException
        Writes a binary plist file with the given object as the root.
        Parameters:
        root - The source of the data to write to the file.
        path - The path of the file to write to.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
      • write

        @Deprecated
        public static void write​(java.io.OutputStream out,
                                 NSObject root)
                          throws java.io.IOException
        Deprecated.
        Use the overload that takes the root as first argument and the stream as second.
        Writes a binary plist serialization of the given object as the root. This method does not close the output stream.
        Parameters:
        out - The stream to write to.
        root - The source of the data to write to the stream.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
      • write

        public static void write​(NSObject root,
                                 java.io.OutputStream out)
                          throws java.io.IOException
        Writes a binary plist serialization of the given object as the root. This method does not close the output stream.
        Parameters:
        root - The source of the data to write to the stream.
        out - The stream to write to.
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
      • writeToArray

        public static byte[] writeToArray​(NSObject root)
                                   throws java.io.IOException
        Writes a binary plist serialization of the given object as the root into a byte array.
        Parameters:
        root - The root object of the property list
        Returns:
        The byte array containing the serialized property list
        Throws:
        java.io.IOException - If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
      • write

        void write​(NSObject root)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • assignID

        void assignID​(NSObject obj)
      • computeIdSizeInBytes

        private static int computeIdSizeInBytes​(int numberOfIds)
      • computeOffsetSizeInBytes

        private int computeOffsetSizeInBytes​(long maxOffset)
      • writeIntHeader

        void writeIntHeader​(int kind,
                            int value)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        void write​(int b)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        void write​(byte[] bytes)
            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBytes

        void writeBytes​(long value,
                        int bytes)
                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeID

        void writeID​(int id)
              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeLong

        void writeLong​(long value)
                throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDouble

        void writeDouble​(double value)
                  throws java.io.IOException
        Throws:
        java.io.IOException