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
FieldsModifier and TypeFieldDescriptionprivate static final DocumentBuilderFactoryprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Transformerprivate static XMLReaderfilterElementNodes(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 NSObjectparse(byte[] bytes, boolean withLineInformation) Parses an XML property list from a byte array.static NSObjectParses an XML property list file.static NSObjectParses an XML property list file.static NSObjectparse(InputStream is) Parses an XML property list from an input stream.static NSObjectparse(InputStream is, boolean withLineInformation) Parses an XML property list from an input stream.static NSObjectParses an XML property list from aReader.static NSObjectParses an XML property list from aReader.static NSObjectParses an XML property list file.static NSObjectParses an XML property list file.static NSObjectParses a property list from an XML document.private static NSObjectparseObject(Node n, String xpath, int depth) Parses a node in the XML structure and returns the corresponding NSObjectprivate static DocumentparseXml(InputSource inputSource, boolean withLineInformation)
-
Field Details
-
FACTORY
-
FEATURE_LOAD_EXTERNAL_DTD
- See Also:
-
FEATURE_EXTERNAL_GENERAL_ENTITIES
- See Also:
-
FEATURE_EXTERNAL_PARAMETER_ENTITIES
- See Also:
-
-
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 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
public static NSObject parse(Path path) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
public static NSObject parse(byte[] bytes) throws ParserConfigurationException, 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.
-
parse
public static NSObject parse(InputStream is) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
public static NSObject parse(Reader reader) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
public static NSObject parse(File f, boolean withLineInformation) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException Parses an XML property list file.- Parameters:
f- The XML property list file.withLineInformation- If set totrue, the parser will try to collect line information and store it in the parsed object's location information (SeeNSObject.getLocationInformation()).- 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
public static NSObject parse(Path path, boolean withLineInformation) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException Parses an XML property list file.- Parameters:
path- The XML property list file path.withLineInformation- If set totrue, the parser will try to collect line information and store it in the parsed object's location information- 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
public static NSObject parse(byte[] bytes, boolean withLineInformation) throws ParserConfigurationException, SAXException, PropertyListFormatException, IOException Parses an XML property list from a byte array.- Parameters:
bytes- The byte array containing the property list's data.withLineInformation- If set totrue, the parser will try to collect line information and store it in the parsed object's location information- 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.
-
parse
public static NSObject parse(InputStream is, boolean withLineInformation) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException 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.withLineInformation- If set totrue, the parser will try to collect line information and store it in the parsed object's location information- 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
public static NSObject parse(Reader reader, boolean withLineInformation) throws ParserConfigurationException, IOException, SAXException, PropertyListFormatException 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.withLineInformation- If set totrue, the parser will try to collect line information and store it in the parsed object's location information- 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 XML parsing error occurs.PropertyListFormatException- If the given property list has an invalid format.- See Also:
-
parse
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.
-
parseXml
private static Document parseXml(InputSource inputSource, boolean withLineInformation) throws IOException, SAXException, ParserConfigurationException -
createSafeXmlReader
-
createSafeTransformer
-
parseObject
private static NSObject parseObject(Node n, String xpath, int depth) throws PropertyListFormatException Parses a node in the XML structure and returns the corresponding NSObject- Parameters:
n- The XML node.depth- The current nesting depth, used to guard against excessively nested structures.- Returns:
- The corresponding NSObject.
- Throws:
PropertyListFormatException- A parsing error occurred.
-
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.
-