Top Description Fields Constructors Methods
com.dd.plist

public Class PropertyListParser

extends Object
Class Inheritance
Imports
org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException, java.io.BufferedInputStream, .ByteArrayInputStream, .ByteArrayOutputStream, .File, .IOException, .InputStream, .OutputStream, java.nio.charset.Charset, java.nio.file.FileSystems, .Files, .Path, java.text.ParseException, java.util.Objects

Parses property lists. The parser can handle files, input streams and byte arrays. All known property list formats are supported.
Author
Daniel Dreibrodt

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
protected
PropertyListParser()

Prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
public static void
convertToASCII(File
The source file.
in
,
File
The target file. If the file's parent directory does not exist, it will be created.
out
)
Deprecated Use PropertyListConverter instead.

Converts a given property list file into ASCII format.

public static void
convertToBinary(File
The source file.
in
,
File
The target file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use PropertyListConverter instead.

Converts a given property list file into the OS X and iOS binary format.

public static void
convertToGnuStepASCII(File
The source file.
in
,
File
The target file.
out
)
Deprecated Use PropertyListConverter instead.

Converts a given property list file into ASCII format.

public static void
convertToXml(File
The source file.
in
,
File
The target file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use PropertyListConverter instead.

Converts a given property list file into the OS X and iOS XML format.

private static int

Returns:

The type of the property list.
determineType
(String
The very first bytes of data of the property list (minus any whitespace) as a string.
dataBeginning
)

Determines the property list type by means of the first bytes of its data.

private static int

Returns:

The type of the property list.
determineType
(InputStream
An input stream pointing to the beginning of the property list data. If the stream supports marking it will be reset to the beginning of the property list data after the type has been determined.
is
,
int
The number of bytes to skip in the stream.
offset
)

Determines the property list type by means of the first bytes of its data.

public static NSObject

Returns:

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.
parse
(String
The path to the property list file.
filePath
)

Parses a property list from a file.

public static NSObject

Returns:

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.
parse
(File
The property list file.
f
)

Parses a property list from a file.

public static NSObject

Returns:

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.
parse
(Path
The path to the property list file.
path
)

Parses a property list from a file.

public static NSObject

Returns:

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.
parse
(byte[]
The property list data as a byte array.
bytes
)

Parses a property list from a byte array.

public static NSObject

Returns:

The root object of the property list. This is usually a NSDictionary but can also be a NSArray.
parse
(InputStream
The InputStream delivering the property list data.
is
)

Parses a property list from an InputStream.

protected static byte[]

Returns:

An array containing all bytes that were read from the input stream.
readAll
(InputStream
The InputStream pointing to the data that should be stored in the array.
in
)

Reads all bytes from an InputStream and stores them in an array, up to a maximum count.

public static void
saveAsASCII(NSDictionary
The root object.
root
,
File
The output file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

public static void
saveAsASCII(NSArray
The root object.
root
,
File
The output file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

public static void
saveAsBinary(NSObject
The root object.
root
,
File
The output file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use BinaryPropertyListWriter instead.

Saves a property list with the given object as root into a binary file.

public static void
saveAsBinary(NSObject
The root object.
root
,
OutputStream
The output stream.
out
)
Deprecated Use BinaryPropertyListWriter instead.

Saves a property list with the given object as root in binary format into an output stream.

public static void
saveAsGnuStepASCII(NSDictionary
The root object.
root
,
File
The output file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

public static void
saveAsGnuStepASCII(NSArray
The root object.
root
,
File
The output file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

public static void
saveAsXML(NSObject
The root object.
root
,
File
The output file. If the output file's parent directory does not exist, it will be created.
out
)
Deprecated Use XMLPropertyListWriter instead.

Saves a property list with the given object as root into an XML file.

public static void
saveAsXML(NSObject
The root object.
root
,
OutputStream
The output stream.
out
)
Deprecated Use XMLPropertyListWriter instead.

Saves a property list with the given object as root in XML format into an output stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

READ_BUFFER_LENGTHback to summary
private static final int READ_BUFFER_LENGTH
TYPE_ASCIIback to summary
private static final int TYPE_ASCII
TYPE_BINARYback to summary
private static final int TYPE_BINARY
TYPE_ERROR_BLANKback to summary
private static final int TYPE_ERROR_BLANK
TYPE_ERROR_UNKNOWNback to summary
private static final int TYPE_ERROR_UNKNOWN
TYPE_XMLback to summary
private static final int TYPE_XML

Constructor Detail

PropertyListParserback to summary
protected PropertyListParser()

Prevent instantiation.

Method Detail

convertToASCIIback to summary
public static void convertToASCII(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException

Deprecated

Use PropertyListConverter instead.

Converts a given property list file into ASCII format.

Parameters
in:File

The source file.

out:File

The target file. If the file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
ParserConfigurationException:
If a document builder for parsing a XML property list could not be created. This should not occur.
ParseException:
If a date string could not be parsed.
SAXException:
If any parse error occurs.
PropertyListFormatException:
If the given property list has an invalid format.
IOException:
If any I/O error occurs while reading the input file or writing the output file.
convertToBinaryback to summary
public static void convertToBinary(File in, File out) throws IOException, ParserConfigurationException, ParseException, SAXException, PropertyListFormatException

Deprecated

Use PropertyListConverter instead.

Converts a given property list file into the OS X and iOS binary format.

Parameters
in:File

The source file.

out:File

The target file. If the output file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
IOException:
If any I/O error occurs while reading the input file or writing the output file.
ParserConfigurationException:
If a document builder for parsing a XML property list could not be created. This should not occur.
ParseException:
If a date string could not be parsed.
SAXException:
If any parse error occurs.
PropertyListFormatException:
If the given property list has an invalid format.
convertToGnuStepASCIIback to summary
public static void convertToGnuStepASCII(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException

Deprecated

Use PropertyListConverter instead.

Converts a given property list file into ASCII format.

Parameters
in:File

The source file.

out:File

The target file.

Annotations
@Deprecated
Exceptions
ParserConfigurationException:
If a document builder for parsing a XML property list could not be created. This should not occur.
ParseException:
If a date string could not be parsed.
SAXException:
If any parse error occurs.
PropertyListFormatException:
If the given property list has an invalid format.
IOException:
If any I/O error occurs while reading the input file or writing the output file.
convertToXmlback to summary
public static void convertToXml(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException

Deprecated

Use PropertyListConverter instead.

Converts a given property list file into the OS X and iOS XML format.

Parameters
in:File

The source file.

out:File

The target file. If the output file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
ParserConfigurationException:
If a document builder for parsing an XML property list could not be created. This should not occur.
ParseException:
If a date string could not be parsed.
SAXException:
If any parse error occurs.
PropertyListFormatException:
If the given property list has an invalid format.
IOException:
If any I/O error occurs while reading the input file or writing the output file.
determineTypeback to summary
private static int determineType(String dataBeginning)

Determines the property list type by means of the first bytes of its data.

Parameters
dataBeginning:String

The very first bytes of data of the property list (minus any whitespace) as a string.

Returns:int

The type of the property list.

determineTypeback to summary
private static int determineType(InputStream is, int offset) throws IOException

Determines the property list type by means of the first bytes of its data.

Parameters
is:InputStream

An input stream pointing to the beginning of the property list data. If the stream supports marking it will be reset to the beginning of the property list data after the type has been determined.

offset:int

The number of bytes to skip in the stream.

Returns:int

The type of the property list.

parseback to summary
public static NSObject parse(String filePath) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException

Parses a property list from a file.

Parameters
filePath:String

The path to the property list file.

Returns:NSObject

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.

Exceptions
ParserConfigurationException:
If a document builder for parsing an XML property list could not be created. This should not occur.
ParseException:
If the given property list has an invalid format.
SAXException:
If any parse error occurs.
PropertyListFormatException:
If the given property list has an invalid format.
IOException:
If any I/O error occurs while reading the file.
parseback to summary
public static NSObject parse(File f) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException

Parses a property list from a file.

Parameters
f:File

The property list file.

Returns:NSObject

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.

Exceptions
IOException:
If any I/O error occurs while reading the file.
PropertyListFormatException:
If the given property list has an invalid format.
ParseException:
If the given property list has an invalid format.
ParserConfigurationException:
If a document builder for parsing an XML property list could not be created. This should not occur.
SAXException:
If any parse error occurs.
parseback to summary
public static NSObject parse(Path path) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException

Parses a property list from a file.

Parameters
path:Path

The path to the property list file.

Returns:NSObject

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.

Exceptions
IOException:
If any I/O error occurs while reading the file.
PropertyListFormatException:
If the given property list has an invalid format.
ParseException:
If the given property list has an invalid format.
ParserConfigurationException:
If a document builder for parsing an XML property list could not be created. This should not occur.
SAXException:
If any parse error occurs.
parseback to summary
public static NSObject parse(byte[] bytes) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException

Parses a property list from a byte array.

Parameters
bytes:byte[]

The property list data as a byte array.

Returns:NSObject

The root object in the property list. This is usually a NSDictionary but can also be a NSArray.

Exceptions
IOException:
If any I/O error occurs while reading the byte array.
PropertyListFormatException:
If the given property list has an invalid format.
ParseException:
If the given property list has an invalid format.
ParserConfigurationException:
If a document builder for parsing an XML property list could not be created. This should not occur.
SAXException:
If any parse error occurs.
parseback to summary
public static NSObject parse(InputStream is) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException

Parses a property list from an InputStream. This method does not close the specified input stream.

Parameters
is:InputStream

The InputStream delivering the property list data.

Returns:NSObject

The root object of the property list. This is usually a NSDictionary but can also be a NSArray.

Exceptions
IOException:
If any I/O error occurs while reading the input stream.
PropertyListFormatException:
If the given property list has an invalid format.
ParseException:
If the given property list has an invalid format.
ParserConfigurationException:
If a document builder for parsing an XML property list could not be created. This should not occur.
SAXException:
If any parse error occurs.
readAllback to summary
protected static byte[] readAll(InputStream in) throws IOException

Reads all bytes from an InputStream and stores them in an array, up to a maximum count.

Parameters
in:InputStream

The InputStream pointing to the data that should be stored in the array.

Returns:byte[]

An array containing all bytes that were read from the input stream.

Exceptions
IOException:
If an I/O error occurs while reading from the input stream.
saveAsASCIIback to summary
public static void saveAsASCII(NSDictionary root, File out) throws IOException

Deprecated

Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

Parameters
root:NSDictionary

The root object.

out:File

The output file. If the output file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
IOException:
If an error occurs during the writing process.
saveAsASCIIback to summary
public static void saveAsASCII(NSArray root, File out) throws IOException

Deprecated

Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

Parameters
root:NSArray

The root object.

out:File

The output file. If the output file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
IOException:
If an error occurs during the writing process.
saveAsBinaryback to summary
public static void saveAsBinary(NSObject root, File out) throws IOException

Deprecated

Use BinaryPropertyListWriter instead.

Saves a property list with the given object as root into a binary file.

Parameters
root:NSObject

The root object.

out:File

The output file. If the output file's parent directory does not exist, it will be created.

Exceptions
IOException:
If an error occurs during the writing process.
saveAsBinaryback to summary
public static void saveAsBinary(NSObject root, OutputStream out) throws IOException

Deprecated

Use BinaryPropertyListWriter instead.

Saves a property list with the given object as root in binary format into an output stream. This method does not close the specified input stream.

Parameters
root:NSObject

The root object.

out:OutputStream

The output stream.

Annotations
@Deprecated
Exceptions
IOException:
If an error occurs during the writing process.
saveAsGnuStepASCIIback to summary
public static void saveAsGnuStepASCII(NSDictionary root, File out) throws IOException

Deprecated

Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

Parameters
root:NSDictionary

The root object.

out:File

The output file. If the output file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
IOException:
If an error occurs during the writing process.
saveAsGnuStepASCIIback to summary
public static void saveAsGnuStepASCII(NSArray root, File out) throws IOException

Deprecated

Use ASCIIPropertyListWriter instead.

Saves a property list with the given object as root into an ASCII file.

Parameters
root:NSArray

The root object.

out:File

The output file. If the output file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
IOException:
If an error occurs during the writing process.
saveAsXMLback to summary
public static void saveAsXML(NSObject root, File out) throws IOException

Deprecated

Use XMLPropertyListWriter instead.

Saves a property list with the given object as root into an XML file.

Parameters
root:NSObject

The root object.

out:File

The output file. If the output file's parent directory does not exist, it will be created.

Annotations
@Deprecated
Exceptions
IOException:
If an error occurs during the writing process.
saveAsXMLback to summary
public static void saveAsXML(NSObject root, OutputStream out) throws IOException

Deprecated

Use XMLPropertyListWriter instead.

Saves a property list with the given object as root in XML format into an output stream. This method does not close the specified output stream.

Parameters
root:NSObject

The root object.

out:OutputStream

The output stream.

Annotations
@Deprecated
Exceptions
IOException:
If an error occurs during the writing process.