diff -r 6dcea85ad8ba -r 75acc009e9d8 src/share/classes/java/util/XMLUtils.java --- a/src/share/classes/java/util/XMLUtils.java Mon Jun 22 18:07:11 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ -/* - * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -package java.util; - -import java.io.*; -import org.xml.sax.*; -import org.xml.sax.helpers.*; -import org.w3c.dom.*; -import javax.xml.parsers.*; -import javax.xml.transform.*; -import javax.xml.transform.dom.*; -import javax.xml.transform.stream.*; - -/** - * A class used to aid in Properties load and save in XML. Keeping this - * code outside of Properties helps reduce the number of classes loaded - * when Properties is loaded. - * - * @author Michael McCloskey - * @since 1.3 - */ -class XMLUtils { - - // XML loading and saving methods for Properties - - // The required DTD URI for exported properties - private static final String PROPS_DTD_URI = - "http://java.sun.com/dtd/properties.dtd"; - - private static final String PROPS_DTD = - "" + - "" + - ""+ - "" + - "" + - "" + - ""; - - /** - * Version number for the format of exported properties files. - */ - private static final String EXTERNAL_XML_VERSION = "1.0"; - - static void load(Properties props, InputStream in) - throws IOException, InvalidPropertiesFormatException - { - Document doc = null; - try { - doc = getLoadingDoc(in); - } catch (SAXException saxe) { - throw new InvalidPropertiesFormatException(saxe); - } - Element propertiesElement = (Element)doc.getChildNodes().item(1); - String xmlVersion = propertiesElement.getAttribute("version"); - if (xmlVersion.compareTo(EXTERNAL_XML_VERSION) > 0) - throw new InvalidPropertiesFormatException( - "Exported Properties file format version " + xmlVersion + - " is not supported. This java installation can read" + - " versions " + EXTERNAL_XML_VERSION + " or older. You" + - " may need to install a newer version of JDK."); - importProperties(props, propertiesElement); - } - - static Document getLoadingDoc(InputStream in) - throws SAXException, IOException - { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setIgnoringElementContentWhitespace(true); - dbf.setValidating(true); - dbf.setCoalescing(true); - dbf.setIgnoringComments(true); - try { - DocumentBuilder db = dbf.newDocumentBuilder(); - db.setEntityResolver(new Resolver()); - db.setErrorHandler(new EH()); - InputSource is = new InputSource(in); - return db.parse(is); - } catch (ParserConfigurationException x) { - throw new Error(x); - } - } - - static void importProperties(Properties props, Element propertiesElement) { - NodeList entries = propertiesElement.getChildNodes(); - int numEntries = entries.getLength(); - int start = numEntries > 0 && - entries.item(0).getNodeName().equals("comment") ? 1 : 0; - for (int i=start; i