Package com.dd.plist
Class XMLPropertyListParser
- java.lang.Object
-
- com.dd.plist.XMLPropertyListParser
-
public class XMLPropertyListParser extends java.lang.ObjectParses XML property lists.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classXMLPropertyListParser.PlistDtdResolverOffline resolver for Apple's PLIST DTDs.
-
Field Summary
Fields Modifier and Type Field Description private static javax.xml.parsers.DocumentBuilderFactoryFACTORY
-
Constructor Summary
Constructors Constructor Description XMLPropertyListParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.util.List<org.w3c.dom.Node>filterElementNodes(org.w3c.dom.NodeList list)Returns all element nodes that are contained in a list of nodes.static javax.xml.parsers.DocumentBuildergetDocBuilder()Gets aDocumentBuilderto parse an XML property list.private static java.lang.StringgetNodeTextContents(org.w3c.dom.Node n)Returns a node's text content.static NSObjectparse(byte[] bytes)Parses an XML property list from a byte array.static NSObjectparse(java.io.File f)Parses an XML property list file.static NSObjectparse(java.io.InputStream is)Parses an XML property list from an input stream.static NSObjectparse(java.io.Reader reader)Parses an XML property list from aReader.static NSObjectparse(java.nio.file.Path path)Parses an XML property list file.static NSObjectparse(org.w3c.dom.Document doc)Parses a property list from an XML document.private static NSObjectparseObject(org.w3c.dom.Node n)Parses a node in the XML structure and returns the corresponding NSObject
-
-
-
Method Detail
-
getDocBuilder
public static javax.xml.parsers.DocumentBuilder getDocBuilder() throws javax.xml.parsers.ParserConfigurationExceptionGets 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:
javax.xml.parsers.ParserConfigurationException- If a document builder for parsing a XML property list could not be created. This should not occur.
-
parse
public static NSObject parse(java.io.File f) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException, PropertyListFormatException, java.text.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:
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 a number or date string could not be parsed.- See Also:
DocumentBuilder.parse(java.io.File)
-
parse
public static NSObject parse(java.nio.file.Path path) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException, PropertyListFormatException, java.text.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:
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 a number or date string could not be parsed.- See Also:
DocumentBuilder.parse(java.io.File)
-
parse
public static NSObject parse(byte[] bytes) throws javax.xml.parsers.ParserConfigurationException, java.text.ParseException, org.xml.sax.SAXException, PropertyListFormatException, java.io.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:
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 a number or date string could not be parsed.
-
parse
public static NSObject parse(java.io.InputStream is) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException, PropertyListFormatException, java.text.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:
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 a number or date string could not be parsed.- See Also:
DocumentBuilder.parse(java.io.InputStream)
-
parse
public static NSObject parse(java.io.Reader reader) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException, PropertyListFormatException, java.text.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:
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 a number or date string could not be parsed.- See Also:
DocumentBuilder.parse(java.io.InputStream)
-
parse
public static NSObject parse(org.w3c.dom.Document doc) throws PropertyListFormatException, java.io.IOException, java.text.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:
java.io.IOException- If any I/O error occurs while reading the file.PropertyListFormatException- If the given property list has an invalid format.java.text.ParseException- If a number or date string could not be parsed.
-
parseObject
private static NSObject parseObject(org.w3c.dom.Node n) throws java.text.ParseException, java.io.IOException
Parses a node in the XML structure and returns the corresponding NSObject- Parameters:
n- The XML node.- Returns:
- The corresponding NSObject.
- Throws:
java.io.IOException- If any I/O error occurs while parsing a Base64 encoded NSData object.java.text.ParseException- If a number or date string could not be parsed.
-
filterElementNodes
private static java.util.List<org.w3c.dom.Node> filterElementNodes(org.w3c.dom.NodeList list)
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
private static java.lang.String getNodeTextContents(org.w3c.dom.Node n)
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.
-
-