Package com.dd.plist
Class XMLPropertyListParser
java.lang.Object
com.dd.plist.XMLPropertyListParser
Parses XML property lists.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classOffline resolver for Apple's PLIST DTDs. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfilterElementNodes(NodeList list) Returns all element nodes that are contained in a list of nodes.static DocumentBuilderGets aDocumentBuilderto parse an XML property list.private static StringReturns a node's text content.static NSObjectparse(byte[] bytes) Parses an XML property list from a byte array.static NSObjectParses an XML property list file.static NSObjectparse(InputStream is) Parses an XML property list from an input stream.static NSObjectParses an XML property list from aReader.static NSObjectParses an XML property list file.static NSObjectParses a property list from an XML document.private static NSObjectparseObject(Node n) Parses a node in the XML structure and returns the corresponding NSObject
-
Field Details
-
FACTORY
-
-
Constructor Details
-
XMLPropertyListParser
public XMLPropertyListParser()
-
-
Method Details
-
getDocBuilder
Gets aDocumentBuilderto parse an XML property list. AsDocumentBuilderinstance are not thread-safe a newDocumentBuilderis generated for each request.- Returns:
- A new
DocumentBuilderthat can parse property lists without an internet connection. - Throws:
ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.
-
parse
public static NSObject parse(File f) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException, ParseException Parses an XML property list file.- Parameters:
f- The XML property list file.- 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 file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a number or date string could not be parsed.- See Also:
-
parse
public static NSObject parse(Path path) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException, ParseException Parses an XML property list file.- Parameters:
path- The XML property list file path.- 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 file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a number or date string could not be parsed.- See Also:
-
parse
public static NSObject parse(byte[] bytes) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException Parses an XML property list from a byte array.- Parameters:
bytes- The byte array containing the property list's 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 file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a number or date string could not be parsed.
-
parse
public static NSObject parse(InputStream is) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException, ParseException Parses an XML property list from an input stream. This method does not close the specified input stream.- Parameters:
is- The input stream pointing to the property list's 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 file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a number or date string could not be parsed.- See Also:
-
parse
public static NSObject parse(Reader reader) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException, ParseException Parses an XML property list from aReader. This method does not close the specified reader.- Parameters:
reader- The reader providing the property list's 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 file.SAXException- If any parse error occurs.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a number or date string could not be parsed.- See Also:
-
parse
public static NSObject parse(Document doc) throws PropertyListFormatException, IOException, ParseException Parses a property list from an XML document.- Parameters:
doc- The XML document.- Returns:
- The root NSObject of the property list contained in the XML document.
- Throws:
IOException- If any I/O error occurs while reading the file.PropertyListFormatException- If the given property list has an invalid format.ParseException- If a number or date string could not be parsed.
-
parseObject
Parses a node in the XML structure and returns the corresponding NSObject- Parameters:
n- The XML node.- Returns:
- The corresponding NSObject.
- Throws:
IOException- If any I/O error occurs while parsing a Base64 encoded NSData object.ParseException- If a number or date string could not be parsed.
-
filterElementNodes
Returns all element nodes that are contained in a list of nodes.- Parameters:
list- The list of nodes to search.- Returns:
- The sub-list containing only nodes representing actual elements.
-
getNodeTextContents
Returns a node's text content. This method will return the text value represented by the node's direct children. If the given node is a TEXT or CDATA node, then its value is returned.- Parameters:
n- The node.- Returns:
- The node's text content.
-