Package com.dd.plist
Class PropertyListParser
- java.lang.Object
-
- com.dd.plist.PropertyListParser
-
public class PropertyListParser extends java.lang.ObjectParses property lists. The parser can handle files, input streams and byte arrays. All known property list formats are supported.
-
-
Field Summary
Fields Modifier and Type Field Description private static intREAD_BUFFER_LENGTHprivate static intTYPE_ASCIIprivate static intTYPE_BINARYprivate static intTYPE_ERROR_BLANKprivate static intTYPE_ERROR_UNKNOWNprivate static intTYPE_XML
-
Constructor Summary
Constructors Modifier Constructor Description protectedPropertyListParser()Prevent instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidconvertToASCII(java.io.File in, java.io.File out)Deprecated.UsePropertyListConverterinstead.static voidconvertToBinary(java.io.File in, java.io.File out)Deprecated.UsePropertyListConverterinstead.static voidconvertToGnuStepASCII(java.io.File in, java.io.File out)Deprecated.UsePropertyListConverterinstead.static voidconvertToXml(java.io.File in, java.io.File out)Deprecated.UsePropertyListConverterinstead.private static intdetermineType(java.io.InputStream is, int offset)Determines the property list type by means of the first bytes of its data.private static intdetermineType(java.lang.String dataBeginning)Determines the property list type by means of the first bytes of its data.static NSObjectparse(byte[] bytes)Parses a property list from a byte array.static NSObjectparse(java.io.File f)Parses a property list from a file.static NSObjectparse(java.io.InputStream is)Parses a property list from an InputStream.static NSObjectparse(java.lang.String filePath)Parses a property list from a file.static NSObjectparse(java.nio.file.Path path)Parses a property list from a file.protected static byte[]readAll(java.io.InputStream in)Reads all bytes from an InputStream and stores them in an array, up to a maximum count.static voidsaveAsASCII(NSArray root, java.io.File out)Deprecated.UseASCIIPropertyListWriterinstead.static voidsaveAsASCII(NSDictionary root, java.io.File out)Deprecated.UseASCIIPropertyListWriterinstead.static voidsaveAsBinary(NSObject root, java.io.File out)Deprecated.UseBinaryPropertyListWriterinstead.static voidsaveAsBinary(NSObject root, java.io.OutputStream out)Deprecated.UseBinaryPropertyListWriterinstead.static voidsaveAsGnuStepASCII(NSArray root, java.io.File out)Deprecated.UseASCIIPropertyListWriterinstead.static voidsaveAsGnuStepASCII(NSDictionary root, java.io.File out)Deprecated.UseASCIIPropertyListWriterinstead.static voidsaveAsXML(NSObject root, java.io.File out)Deprecated.UseXMLPropertyListWriterinstead.static voidsaveAsXML(NSObject root, java.io.OutputStream out)Deprecated.UseXMLPropertyListWriterinstead.
-
-
-
Field Detail
-
TYPE_XML
private static final int TYPE_XML
- See Also:
- Constant Field Values
-
TYPE_BINARY
private static final int TYPE_BINARY
- See Also:
- Constant Field Values
-
TYPE_ASCII
private static final int TYPE_ASCII
- See Also:
- Constant Field Values
-
TYPE_ERROR_BLANK
private static final int TYPE_ERROR_BLANK
- See Also:
- Constant Field Values
-
TYPE_ERROR_UNKNOWN
private static final int TYPE_ERROR_UNKNOWN
- See Also:
- Constant Field Values
-
READ_BUFFER_LENGTH
private static final int READ_BUFFER_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
determineType
private static int determineType(java.lang.String dataBeginning)
Determines the property list type by means of the first bytes of its data.- Parameters:
dataBeginning- The very first bytes of data of the property list (minus any whitespace) as a string.- Returns:
- The type of the property list.
-
determineType
private static int determineType(java.io.InputStream is, int offset) throws java.io.IOExceptionDetermines the property list type by means of the first bytes of its data.- Parameters:
is- 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- The number of bytes to skip in the stream.- Returns:
- The type of the property list.
- Throws:
java.io.IOException
-
readAll
protected static byte[] readAll(java.io.InputStream in) throws java.io.IOExceptionReads 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:
java.io.IOException- If an I/O error occurs while reading from the input stream.
-
parse
public static NSObject parse(java.lang.String filePath) throws javax.xml.parsers.ParserConfigurationException, java.text.ParseException, org.xml.sax.SAXException, PropertyListFormatException, java.io.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the file.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If the given property list has an invalid format.
-
parse
public static NSObject parse(java.io.File f) throws java.io.IOException, PropertyListFormatException, java.text.ParseException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the file.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If the given property list has an invalid format.
-
parse
public static NSObject parse(java.nio.file.Path path) throws java.io.IOException, PropertyListFormatException, java.text.ParseException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the file.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If the given property list has an invalid format.
-
parse
public static NSObject parse(byte[] bytes) throws java.io.IOException, PropertyListFormatException, java.text.ParseException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the byte array.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If the given property list has an invalid format.
-
parse
public static NSObject parse(java.io.InputStream is) throws java.io.IOException, PropertyListFormatException, java.text.ParseException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the input stream.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If the given property list has an invalid format.
-
saveAsXML
@Deprecated public static void saveAsXML(NSObject root, java.io.File out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
saveAsXML
@Deprecated public static void saveAsXML(NSObject root, java.io.OutputStream out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
convertToXml
@Deprecated public static void convertToXml(java.io.File in, java.io.File out) throws javax.xml.parsers.ParserConfigurationException, java.text.ParseException, org.xml.sax.SAXException, PropertyListFormatException, java.io.IOExceptionDeprecated.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing an XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the input file or writing the output file.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If a date string could not be parsed.
-
saveAsBinary
public static void saveAsBinary(NSObject root, java.io.File out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
saveAsBinary
@Deprecated public static void saveAsBinary(NSObject root, java.io.OutputStream out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
convertToBinary
@Deprecated public static void convertToBinary(java.io.File in, java.io.File out) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, java.text.ParseException, org.xml.sax.SAXException, PropertyListFormatExceptionDeprecated.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the input file or writing the output file.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If a date string could not be parsed.
-
saveAsASCII
@Deprecated public static void saveAsASCII(NSDictionary root, java.io.File out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
saveAsASCII
@Deprecated public static void saveAsASCII(NSArray root, java.io.File out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
convertToASCII
@Deprecated public static void convertToASCII(java.io.File in, java.io.File out) throws javax.xml.parsers.ParserConfigurationException, java.text.ParseException, org.xml.sax.SAXException, PropertyListFormatException, java.io.IOExceptionDeprecated.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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the input file or writing the output file.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If a date string could not be parsed.
-
saveAsGnuStepASCII
@Deprecated public static void saveAsGnuStepASCII(NSDictionary root, java.io.File out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
saveAsGnuStepASCII
@Deprecated public static void saveAsGnuStepASCII(NSArray root, java.io.File out) throws java.io.IOException
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:
java.io.IOException- If an error occurs during the writing process.
-
convertToGnuStepASCII
@Deprecated public static void convertToGnuStepASCII(java.io.File in, java.io.File out) throws javax.xml.parsers.ParserConfigurationException, java.text.ParseException, org.xml.sax.SAXException, PropertyListFormatException, java.io.IOExceptionDeprecated.UsePropertyListConverterinstead.Converts a given property list file into ASCII format.- Parameters:
in- The source file.out- The target file.- Throws:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.java.io.IOException- If any I/O error occurs while reading the input file or writing the output file.org.xml.sax.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If a date string could not be parsed.
-
-