Top Description Fields Constructors Methods
com.dd.plist

public final Class BinaryPropertyListWriter

extends Object
Class Inheritance
Imports
java.io.BufferedOutputStream, .ByteArrayOutputStream, .File, .IOException, .OutputStream, java.nio.file.Files, .Path, java.util.LinkedHashMap, .Map, .Objects

Writes property lists in the binary format.
Author
Keith Randall

Field Summary

Modifier and TypeField and Description
private long
private final Map<NSObject, Integer>
private int
private final OutputStream
private int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
pack-priv
BinaryPropertyListWriter(OutputStream
The output stream into which the binary property list will be written
outStr
,
int
The binary property list format version.
version
)

Creates a new binary property list writer

Method Summary

Modifier and TypeMethod and Description
pack-priv void
private static int
computeIdSizeInBytes(int numberOfIds)

private int
computeOffsetSizeInBytes(long maxOffset)

pack-priv int
private static int

Returns:

Version code
getMinimumRequiredVersion
(NSObject
Object root
root
)

Finds out the minimum binary property list format version that can be used to save the given NSObject tree.

public static void
write(File
The file to write to.
file
,
NSObject
The source of the data to write to the file.
root
)
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.

public static void
write(NSObject
The source of the data to write to the file.
root
,
File
The file to write to.
file
)

Writes a binary plist file with the given object as the root.

public static void
write(NSObject
The source of the data to write to the file.
root
,
File
The file to write to.
file
,
boolean
If set to true, the file's parent directories will be created.
createParentDirectories
)

Writes a binary plist file with the given object as the root.

public static void
write(NSObject
The source of the data to write to the file.
root
,
Path
The path of the file to write to.
path
)

Writes a binary plist file with the given object as the root.

public static void
write(OutputStream
The stream to write to.
out
,
NSObject
The source of the data to write to the stream.
root
)
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.

public static void
write(NSObject
The source of the data to write to the stream.
root
,
OutputStream
The stream to write to.
out
)

Writes a binary plist serialization of the given object as the root.

pack-priv void
pack-priv void
write(int b)

pack-priv void
write(byte[] bytes)

pack-priv void
writeBytes(long value, int bytes)

pack-priv void
writeDouble(double value)

pack-priv void
writeID(int id)

pack-priv void
writeIntHeader(int kind, int value)

pack-priv void
writeLong(long value)

public static byte[]

Returns:

The byte array containing the serialized property list
writeToArray
(NSObject
The root object of the property list
root
)

Writes a binary plist serialization of the given object as the root into a byte array.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

countback to summary
private long count
idMapback to summary
private final Map<NSObject, Integer> idMap
idSizeInBytesback to summary
private int idSizeInBytes
outback to summary
private final OutputStream out
versionback to summary
private int version
VERSION_00back to summary
private static final int VERSION_00
VERSION_10back to summary
private static final int VERSION_10
VERSION_15back to summary
private static final int VERSION_15
VERSION_20back to summary
private static final int VERSION_20

Constructor Detail

BinaryPropertyListWriterback to summary
pack-priv BinaryPropertyListWriter(OutputStream outStr, int version)

Creates a new binary property list writer

Parameters
outStr:OutputStream

The output stream into which the binary property list will be written

version:int

The binary property list format version.

Method Detail

assignIDback to summary
pack-priv void assignID(NSObject obj)
computeIdSizeInBytesback to summary
private static int computeIdSizeInBytes(int numberOfIds)
computeOffsetSizeInBytesback to summary
private int computeOffsetSizeInBytes(long maxOffset)
getIDback to summary
pack-priv int getID(NSObject obj)
getMinimumRequiredVersionback to summary
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:NSObject

Object root

Returns:int

Version code

writeback to summary
public static void write(File file, NSObject root) throws 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:File

The file to write to.

root:NSObject

The source of the data to write to the file.

Annotations
@Deprecated
Exceptions
IOException:
If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
writeback to summary
public static void write(NSObject root, File file) throws IOException

Writes a binary plist file with the given object as the root.

Parameters
root:NSObject

The source of the data to write to the file.

file:File

The file to write to.

Exceptions
IOException:
If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
writeback to summary
public static void write(NSObject root, File file, boolean createParentDirectories) throws IOException

Writes a binary plist file with the given object as the root.

Parameters
root:NSObject

The source of the data to write to the file.

file:File

The file to write to.

createParentDirectories:boolean

If set to true, the file's parent directories will be created.

Exceptions
IOException:
If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
writeback to summary
public static void write(NSObject root, Path path) throws IOException

Writes a binary plist file with the given object as the root.

Parameters
root:NSObject

The source of the data to write to the file.

path:Path

The path of the file to write to.

Exceptions
IOException:
If an I/O error occurs while writing to the file or the object structure contains data that cannot be saved.
writeback to summary
public static void write(OutputStream out, NSObject root) throws 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:OutputStream

The stream to write to.

root:NSObject

The source of the data to write to the stream.

Annotations
@Deprecated
Exceptions
IOException:
If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
writeback to summary
public static void write(NSObject root, OutputStream out) throws IOException

Writes a binary plist serialization of the given object as the root. This method does not close the output stream.

Parameters
root:NSObject

The source of the data to write to the stream.

out:OutputStream

The stream to write to.

Exceptions
IOException:
If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.
writeback to summary
pack-priv void write(NSObject root) throws IOException
writeback to summary
pack-priv void write(int b) throws IOException
writeback to summary
pack-priv void write(byte[] bytes) throws IOException
writeBytesback to summary
pack-priv void writeBytes(long value, int bytes) throws IOException
writeDoubleback to summary
pack-priv void writeDouble(double value) throws IOException
writeIDback to summary
pack-priv void writeID(int id) throws IOException
writeIntHeaderback to summary
pack-priv void writeIntHeader(int kind, int value) throws IOException
writeLongback to summary
pack-priv void writeLong(long value) throws IOException
writeToArrayback to summary
public static byte[] writeToArray(NSObject root) throws IOException

Writes a binary plist serialization of the given object as the root into a byte array.

Parameters
root:NSObject

The root object of the property list

Returns:byte[]

The byte array containing the serialized property list

Exceptions
IOException:
If an I/O error occurs while writing to the stream or the object structure contains data that cannot be saved.