public class BinaryParser extends PropertyListParser
NSObject
sModifier 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 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
|
protected static byte[] |
ENDMAGIC
Bytes expected near the end of the file
|
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
|
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 long |
offsetTableOffset
Starting address of the offset table
|
protected PropertyListException |
pleResult
The exception indicating why parsing failed
|
static byte |
REAL
Byte mask indicating a real value
|
protected NSObject |
result
The parse result
|
protected long |
rootAddr
Starting address of the root object
|
static byte |
SET
Byte mask indicating a set value (not implemented)
|
protected static byte[] |
STARTMAGIC
Bytes expected at the start of the file
|
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
|
file, input
Constructor and Description |
---|
BinaryParser(java.io.File file) |
BinaryParser(java.io.InputStream input) |
Modifier and Type | Method and Description |
---|---|
protected static int |
getInteger(byte... bytes)
Convert an array of bytes to a integer
|
protected int |
getLength(byte lengthMask)
Read the length
|
protected static long |
getLong(byte... bytes)
Convert an array of bytes to a long
|
NSObject |
parse()
Parse the Property List input (provided in the constructor) to a tree of
NSObject s |
protected NSArray |
parseArray(byte length)
Parse a node to a NSArray on a given start address
|
protected NSString |
parseASCII(byte length)
Parse a node to a NSString on a given start address, parsing with an ASCII charset
|
protected NSData |
parseData(byte length)
Parse a node to a NSData on a given start address
|
protected NSDate |
parseDate(byte length)
Parse a node to a NSDate on a given start address
|
protected NSDictionary |
parseDictionary(byte length)
Parse a node to a NSDictionary on a given start address
|
protected NSInteger |
parseInteger(byte length)
Parse a node to a NSInteger on a given start address
|
protected NSObject |
parseNode(long addr)
Parse a node to a NSObject on a given start address
|
protected NSReal |
parseReal(byte length)
Parse a node to a NSReal on a given start address
|
protected NSObject |
parseSet(byte length)
Parse a NSSet (not implemented)
|
protected NSObject |
parseUid(byte length)
Parse a NSUID (not implemented)
|
protected NSString |
parseUnicode(byte length)
Parse a node to a NSString on a given start address, parsing with an unicode charset
|
parse, parse
protected static final byte[] STARTMAGIC
protected static final byte[] ENDMAGIC
protected byte offsetEntrySize
protected byte objRefSize
protected int numObjects
protected long rootAddr
protected long offsetTableOffset
protected int[] offsetTable
protected NSObject result
protected PropertyListException pleResult
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 BinaryParser(java.io.File file) throws PropertyListException, java.io.IOException
PropertyListException
java.io.IOException
PropertyListParser.parse(File)
public BinaryParser(java.io.InputStream input)
protected static long getLong(byte... bytes)
bytes
- the byte array (8 bytes max)protected static int getInteger(byte... bytes)
bytes
- the byte array (4 bytes max)public NSObject parse() throws PropertyListException
NSObject
sparse
in class PropertyListParser
NSObject
of the parsed Property ListPropertyListException
- when parsing the Property List failedprotected NSObject parseNode(long addr) throws java.io.IOException, PropertyListException
addr
- the start addressjava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSInteger parseInteger(byte length) throws java.io.IOException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSReal parseReal(byte length) throws java.io.IOException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSDate parseDate(byte length) throws java.io.IOException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSData parseData(byte length) throws java.io.IOException, PropertyListException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSString parseASCII(byte length) throws java.io.IOException, PropertyListException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSString parseUnicode(byte length) throws java.io.IOException, PropertyListException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSObject parseUid(byte length) throws java.io.IOException, PropertyListException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSArray parseArray(byte length) throws java.io.IOException, PropertyListException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSObject parseSet(byte length) throws java.io.IOException, PropertyListException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected NSDictionary parseDictionary(byte length) throws java.io.IOException, PropertyListException
length
- the length bytejava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing failsprotected int getLength(byte lengthMask) throws java.io.IOException, PropertyListException
Read the length
When the lengthMask is 0xF (0000 1111), an integer follows containing the actual length
lengthMask must be equal or smaller than LENMASK
lengthMask
- the length maskjava.io.IOException
- when reading the stream failed while parsingPropertyListException
- when parsing fails