public class BinaryWriter extends PropertyListWriter
NSObject
s to a binary property listPropertyListWriter.Format
Modifier and Type | Field and Description |
---|---|
static byte |
ARRAY
Byte mask indicating a array value
|
static java.nio.charset.Charset |
ASCIICHARSET
Charset to parse ASCII strings
|
static java.util.regex.Pattern |
ASCIIPATTERN
Pattern used to determine whether a string contains only ASCII characters
|
static byte |
ASCIISTRING
Byte mask indicating a ascii string value
|
static byte |
BOOLFALSE
Byte indicating a
Boolean.FALSE value |
static byte |
BOOLTRUE
Byte indicating a
Boolean.TRUE value |
static byte |
DATA
Byte mask indicating a binary data value
|
static byte |
DATE
Byte mask indicating a date value
|
static byte |
DICT
Byte mask indicating a dictionary value
|
static byte |
FILL
Filler byte
|
static byte |
INT
Byte mask indicating a integer value
|
static byte |
LENMASK
Mask for extracting the length
|
static byte |
NULL
NULL byte
|
protected int |
numObjects
Number of objects in stream
|
protected java.util.List<NSObject> |
objectIndex
Numbered list containing all objects
|
static byte |
OBJMASK
Mask for extracting the objecttype (result must be shifted right 4 bits)
|
protected byte |
objRefSize
Size of object references in bytes
|
protected byte |
offsetEntrySize
Size of offset entries in bytes
|
protected int[] |
offsetTable
The offset table
|
protected int |
pointer
The amount of bytes written
|
static byte |
REAL
Byte mask indicating a real value
|
static byte |
SET
Byte mask indicating a set value (not implemented)
|
protected static byte[] |
STARTMAGIC
Bytes expected at the start of the file
|
protected java.io.OutputStream |
stream
The outputstream
|
static byte |
UID
Byte mask indicating a uid value (not implemented)
|
static java.nio.charset.Charset |
UNICODECHARSET
Charset to parse unicode strings
|
static byte |
UNICODESTRING
Byte mask indicating a unicode string value
|
defaultFormat, root
Constructor and Description |
---|
BinaryWriter(NSObject root) |
Modifier and Type | Method and Description |
---|---|
protected void |
buildObjectIndex(NSObject... objs)
Add all objects to the objectIndex, and search all objects of type
NSDictionary or NSArray for more. |
protected void |
buildObjectIndex(java.lang.String... strings)
Add all strings to the objectIndex as
NSString s |
protected static byte |
getLongLength(long l)
Get amount of bytes required to represent a long
|
protected static byte |
log2ceil(long l)
Calculate the 2log of a long, rounded up to the nearest integer or minimal result
|
protected static byte[] |
longToByteArray(long l,
byte size)
Split a long into bytes, little endian
|
void |
write(java.io.OutputStream stream)
Write the property list to a stream
|
protected long |
writeArray(NSArray obj)
Write an array to the stream
|
protected long |
writeBoolean(NSBoolean obj)
Write a boolean to the stream
|
protected long |
writeData(NSData obj)
Write a data object to the stream
|
protected long |
writeDate(NSDate obj)
Write date to the stream
|
protected long |
writeDictionary(NSDictionary obj)
Write a dictionary to the stream
|
protected long |
writeInteger(NSInteger obj)
Write an integer to the stream
|
protected long |
writeObject(NSObject obj)
Write an object to the stream
|
protected long |
writeObjectHeader(long length,
byte type)
Write the object header consisting of the type and length to the stream
|
protected long |
writeReal(NSReal obj)
Write a real to the stream
|
protected long |
writeString(NSString obj)
Write a string to the stream
|
write, write, write
protected final java.util.List<NSObject> objectIndex
protected static final byte[] STARTMAGIC
public static final java.util.regex.Pattern ASCIIPATTERN
protected byte offsetEntrySize
protected byte objRefSize
protected int numObjects
protected int[] offsetTable
protected int pointer
protected java.io.OutputStream stream
public static final byte NULL
public static final byte BOOLFALSE
Boolean.FALSE
valuepublic static final byte BOOLTRUE
Boolean.TRUE
valuepublic static final byte FILL
public static final byte INT
public static final byte REAL
public static final byte DATE
public static final byte DATA
public static final byte ASCIISTRING
public static final byte UNICODESTRING
public static final byte UID
public static final byte ARRAY
public static final byte SET
public static final byte DICT
public static final byte OBJMASK
public static final byte LENMASK
public static final java.nio.charset.Charset ASCIICHARSET
public static final java.nio.charset.Charset UNICODECHARSET
public BinaryWriter(NSObject root)
protected static byte getLongLength(long l)
l
- the longprotected static byte[] longToByteArray(long l, byte size)
l
- the longsize
- the amount of bytes to outputprotected static byte log2ceil(long l)
l
- the longpublic void write(java.io.OutputStream stream) throws PropertyListException, java.io.IOException
write
in class PropertyListWriter
stream
- the stream to write the property list toPropertyListException
- when generating the property list failsjava.io.IOException
- when writing to the stream failsprotected long writeObject(NSObject obj) throws PropertyListException, java.io.IOException
obj
- the object to writePropertyListException
- if the object could not be converted to binary datajava.io.IOException
- if an I/O error occursprotected long writeObjectHeader(long length, byte type) throws java.io.IOException
length
- the length of the object (units differ between objects)type
- the 4 bits determining the type of the objectjava.io.IOException
- if an I/O error occursprotected long writeArray(NSArray obj) throws java.io.IOException
obj
- the arrayjava.io.IOException
- if an I/O error occursprotected long writeBoolean(NSBoolean obj) throws java.io.IOException
obj
- the booleanjava.io.IOException
- if an I/O error occursprotected long writeData(NSData obj) throws java.io.IOException
obj
- the data objectjava.io.IOException
- if an I/O error occursprotected long writeDate(NSDate obj) throws java.io.IOException
obj
- the datejava.io.IOException
- if an I/O error occursprotected long writeDictionary(NSDictionary obj) throws java.io.IOException
obj
- the dictionaryjava.io.IOException
- if an I/O error occursprotected long writeInteger(NSInteger obj) throws java.io.IOException
obj
- the integerjava.io.IOException
- if an I/O error occursprotected long writeReal(NSReal obj) throws java.io.IOException
obj
- the realjava.io.IOException
- if an I/O error occursprotected long writeString(NSString obj) throws java.io.IOException
obj
- the stringjava.io.IOException
- if an I/O error occursprotected void buildObjectIndex(NSObject... objs)
NSDictionary
or NSArray
for more.objs
- the objectsprotected void buildObjectIndex(java.lang.String... strings)
NSString
sstrings
- the strings