throw new PropertyListFormatException("The given XML property list has no root element!"); } else if (rootNodes.size() == 1) { rootNode = rootNodes.get(0); } else { throw new PropertyListFormatException("The given XML property list has more than one root element!");
/** * Parses a property list from an InputStream. * This method does not close the specified input stream. * * @param is The InputStream delivering the property list data. * @return The root object of the property list. This is usually a {@link NSDictionary} but can also be a {@link NSArray}. * @throws javax.xml.parsers.ParserConfigurationException If a document builder for parsing a XML property list could not be created. * @throws java.io.IOException If any I/O error occurs while reading the input stream. * @throws org.xml.sax.SAXException If any parse error occurs. * @throws com.dd.plist.PropertyListFormatException If the given property list has an invalid format. * @throws java.text.ParseException If the given property list has an invalid format. */ public static NSObject parse(InputStream is) throws IOException, PropertyListFormatException, ParseException, ParserConfigurationException, SAXException { if (!is.markSupported()) { is = new BufferedInputStream(is); } switch(determineType(is, 0)) { case TYPE_BINARY: return BinaryPropertyListParser.parse(is); case TYPE_XML: return XMLPropertyListParser.parse(is); case TYPE_ASCII: return ASCIIPropertyListParser.parse(is); case TYPE_ERROR_BLANK: return null; default: throw new PropertyListFormatException("The given data is not a property list of a supported format."); } }
throw new PropertyListFormatException("Unsupported binary property list format: v" + this.majorVersion + "." + this.minorVersion + ". " + "Version 1.0 and later are not yet supported."); throw new PropertyListFormatException("The binary property list does not contain a complete object offset table."); throw new PropertyListFormatException("The binary property list contains a corrupted object offset table.");
/** * Converts a given property list file into ASCII format. * * @param in The source file. * @param 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. * @throws java.io.IOException If any I/O error occurs while reading the input file or writing the output file. * @throws org.xml.sax.SAXException If any parse error occurs. * @throws com.dd.plist.PropertyListFormatException If the given property list has an invalid format. * @throws java.text.ParseException If a date string could not be parsed. */ public static void convertToGnuStepASCII(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException { NSObject root = parse(in); if(root instanceof NSDictionary) { saveAsGnuStepASCII((NSDictionary) root, out); } else if(root instanceof NSArray) { saveAsGnuStepASCII((NSArray) root, out); } else { throw new PropertyListFormatException("The root of the given input property list " + "is neither a Dictionary nor an Array!"); } } }
/** * Converts a given property list file into ASCII format. * * @param in The source file. * @param 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. * @throws java.io.IOException If any I/O error occurs while reading the input file or writing the output file. * @throws org.xml.sax.SAXException If any parse error occurs. * @throws com.dd.plist.PropertyListFormatException If the given property list has an invalid format. * @throws java.text.ParseException If a date string could not be parsed. */ public static void convertToASCII(File in, File out) throws ParserConfigurationException, ParseException, SAXException, PropertyListFormatException, IOException { NSObject root = parse(in); if(root instanceof NSDictionary) { saveAsASCII((NSDictionary) root, out); } else if(root instanceof NSArray) { saveAsASCII((NSArray) root, out); } else { throw new PropertyListFormatException("The root of the given input property list " + "is neither a Dictionary nor an Array!"); } }
throw new PropertyListFormatException("The given binary property list contains an object of unknown type (" + objType + ")"); throw new PropertyListFormatException("The given binary property list contains a date object of an unknown type ("+objInfo+")"); throw new PropertyListFormatException("The given binary property list contains an object of unknown type (" + objType + ")");