Class PropertyListParser
java.lang.Object
com.dd.plist.PropertyListParser
Parses property lists. The parser can handle files, input streams and byte arrays.
All known property list formats are supported.
- Author:
- Daniel Dreibrodt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconvertToASCII(File in, File out) Deprecated.static voidconvertToBinary(File in, File out) Deprecated.UsePropertyListConverterinstead.static voidconvertToGnuStepASCII(File in, File out) Deprecated.UsePropertyListConverterinstead.static voidconvertToXml(File in, File out) Deprecated.UsePropertyListConverterinstead.static NSObjectparse(byte[] bytes) Parses a property list from a byte array.static NSObjectParses a property list from a file.static NSObjectparse(InputStream is) Parses a property list from an InputStream.static NSObjectParses a property list from a file.static NSObjectParses a property list from a file.protected static byte[]readAll(InputStream in) Reads all bytes from an InputStream and stores them in an array, up to a maximum count.static voidsaveAsASCII(NSArray root, File out) Deprecated.UseASCIIPropertyListWriterinstead.static voidsaveAsASCII(NSDictionary root, File out) Deprecated.UseASCIIPropertyListWriterinstead.static voidsaveAsBinary(NSObject root, File out) Deprecated.UseBinaryPropertyListWriterinstead.static voidsaveAsBinary(NSObject root, OutputStream out) Deprecated.UseBinaryPropertyListWriterinstead.static voidsaveAsGnuStepASCII(NSArray root, File out) Deprecated.UseASCIIPropertyListWriterinstead.static voidsaveAsGnuStepASCII(NSDictionary root, File out) Deprecated.UseASCIIPropertyListWriterinstead.static voidDeprecated.UseXMLPropertyListWriterinstead.static voidsaveAsXML(NSObject root, OutputStream out) Deprecated.UseXMLPropertyListWriterinstead.
-
Constructor Details
-
PropertyListParser
protected PropertyListParser()Prevent instantiation.
-
-
Method Details
-
readAll
Reads all bytes from an InputStream and stores them in an array, up to a maximum count.- Parameters:
in- The InputStream pointing to the data that should be stored in the array.- Returns:
- An array containing all bytes that were read from the input stream.
- Throws:
IOException- If an I/O error occurs while reading from the input stream.
-
parse
public static NSObject parse(String filePath) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException Parses a property list from a file.- Parameters:
filePath- The path to the property list file.- Returns:
- The root object in the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If the given property list has an invalid format.
-
parse
public static NSObject parse(File f) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException Parses a property list from a file.- Parameters:
f- The property list file.- Returns:
- The root object in the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If the given property list has an invalid format.
-
parse
public static NSObject parse(Path path) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException Parses a property list from a file.- Parameters:
path- The path to the property list file.- Returns:
- The root object in the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If the given property list has an invalid format.
-
parse
public static NSObject parse(byte[] bytes) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException Parses a property list from a byte array.- Parameters:
bytes- The property list data as a byte array.- Returns:
- The root object in the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the byte array.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If the given property list has an invalid format.
-
parse
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- The InputStream delivering the property list data.- Returns:
- The root object of the property list. This is usually a
NSDictionarybut can also be aNSArray. - Throws:
ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the input stream.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If the given property list has an invalid format.
-
saveAsXML
Deprecated.UseXMLPropertyListWriterinstead.Saves a property list with the given object as root into an XML file.- Parameters:
root- The root object.out- The output file. If the output file's parent directory does not exist, it will be created.- Throws:
IOException- If an error occurs during the writing process.
-
saveAsXML
Deprecated.UseXMLPropertyListWriterinstead.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- The root object.out- The output stream.- Throws:
IOException- If an error occurs during the writing process.
-
convertToXml
@Deprecated public static void convertToXml(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException Deprecated.UsePropertyListConverterinstead.Converts a given property list file into the OS X and iOS XML format.- Parameters:
in- The source file.out- The target file. If the output file's parent directory does not exist, it will be created.- Throws:
ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the input file or writing the output file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a date string could not be parsed.
-
saveAsBinary
Deprecated.UseBinaryPropertyListWriterinstead.Saves a property list with the given object as root into a binary file.- Parameters:
root- The root object.out- The output file. If the output file's parent directory does not exist, it will be created.- Throws:
IOException- If an error occurs during the writing process.
-
saveAsBinary
Deprecated.UseBinaryPropertyListWriterinstead.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- The root object.out- The output stream.- Throws:
IOException- If an error occurs during the writing process.
-
convertToBinary
@Deprecated public static void convertToBinary(File in, File out) throws IOException, ParserConfigurationException, ParseException, SAXException, PropertyListFormatException Deprecated.UsePropertyListConverterinstead.Converts a given property list file into the OS X and iOS binary format.- Parameters:
in- The source file.out- The target file. If the output file's parent directory does not exist, it will be created.- Throws:
ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the input file or writing the output file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a date string could not be parsed.
-
saveAsASCII
Deprecated.UseASCIIPropertyListWriterinstead.Saves a property list with the given object as root into an ASCII file.- Parameters:
root- The root object.out- The output file. If the output file's parent directory does not exist, it will be created.- Throws:
IOException- If an error occurs during the writing process.
-
saveAsASCII
Deprecated.UseASCIIPropertyListWriterinstead.Saves a property list with the given object as root into an ASCII file.- Parameters:
root- The root object.out- The output file. If the output file's parent directory does not exist, it will be created.- Throws:
IOException- If an error occurs during the writing process.
-
convertToASCII
@Deprecated public static void convertToASCII(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException Deprecated.UsePropertyListConverterinstead.Converts a given property list file into ASCII format.- Parameters:
in- The source file.out- The target file. If the file's parent directory does not exist, it will be created.- Throws:
ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the input file or writing the output file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a date string could not be parsed.
-
saveAsGnuStepASCII
Deprecated.UseASCIIPropertyListWriterinstead.Saves a property list with the given object as root into an ASCII file.- Parameters:
root- The root object.out- The output file. If the output file's parent directory does not exist, it will be created.- Throws:
IOException- If an error occurs during the writing process.
-
saveAsGnuStepASCII
Deprecated.UseASCIIPropertyListWriterinstead.Saves a property list with the given object as root into an ASCII file.- Parameters:
root- The root object.out- The output file. If the output file's parent directory does not exist, it will be created.- Throws:
IOException- If an error occurs during the writing process.
-
convertToGnuStepASCII
@Deprecated public static void convertToGnuStepASCII(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException Deprecated.UsePropertyListConverterinstead.Converts a given property list file into ASCII format.- Parameters:
in- The source file.out- The target file.- Throws:
ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.IOException- If any I/O error occurs while reading the input file or writing the output file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a date string could not be parsed.
-
PropertyListConverterinstead.