2362N/A * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * XML Support for java.util.prefs. Methods to import and export preference 0N/A * nodes and subtrees. 0N/A * @author Josh Bloch and Mark Reinhold 0N/A // The required DTD URI for exported preferences 0N/A // The actual DTD corresponding to the URI 0N/A "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
0N/A "<!-- DTD for preferences -->" +
0N/A "<!ELEMENT preferences (root) >" +
0N/A "<!ATTLIST preferences" +
0N/A " EXTERNAL_XML_VERSION CDATA \"0.0\" >" +
0N/A "<!ELEMENT root (map, node*) >" +
0N/A " type (system|user) #REQUIRED >" +
0N/A "<!ELEMENT node (map, node*) >" +
0N/A " name CDATA #REQUIRED >" +
0N/A "<!ELEMENT map (entry*) >" +
0N/A " MAP_XML_VERSION CDATA \"0.0\" >" +
0N/A "<!ELEMENT entry EMPTY >" +
0N/A " key CDATA #REQUIRED" +
0N/A " value CDATA #REQUIRED >" ;
0N/A * Version number for the format exported preferences files. 0N/A * Version number for the internal map files. 0N/A * Export the specified preferences node and, if subTree is true, all 0N/A * subnodes, to the specified output stream. Preferences are exported as 0N/A * an XML document conforming to the definition in the Preferences spec. 0N/A * @throws IOException if writing to the specified output stream 0N/A * results in an <tt>IOException</tt>. 0N/A * @throws BackingStoreException if preference data cannot be read from 0N/A * @throws IllegalStateException if this node (or an ancestor) has been 0N/A * removed with the {@link #removeNode()} method. 0N/A // Get bottom-up list of nodes from p to root, excluding root 0N/A * Put the preferences in the specified Preferences node into the 0N/A * specified XML element which is assumed to represent a node 0N/A * in the specified XML document which is assumed to conform to 0N/A * PREFS_DTD. If subTree is true, create children of the specified 0N/A * XML node conforming to all of the children of the specified 0N/A * Preferences node and recurse. 0N/A * @throws BackingStoreException if it is not possible to read 0N/A * the preferences or children out of the specified 0N/A // Node is locked to export its contents and get a 0N/A // copy of children, then lock is released, 0N/A // and, if subTree = true, recursive calls are made on children 0N/A // Check if this node was concurrently removed. If yes 0N/A // remove it from XML Document and return. 0N/A // Put map in xml element 0N/A // NEXT STATEMENT THROWS NULL PTR EXC INSTEAD OF ASSERT FAIL 0N/A // Recurse if appropriate 0N/A /* Get a copy of kids while lock is held */ 0N/A * Import preferences from the specified input stream, which is assumed 0N/A * to contain an XML document in the format described in the Preferences 0N/A * @throws IOException if reading from the specified output stream 0N/A * results in an <tt>IOException</tt>. 0N/A * @throws InvalidPreferencesFormatException Data on input stream does not 0N/A * constitute a valid XML document with the mandated document type. 0N/A " is not supported. This java installation can read" +
0N/A " to install a newer version of JDK.");
0N/A * Create a new prefs XML document. 0N/A * Load an XML document from specified input stream, which must 0N/A * have the requisite DTD URI. 0N/A * Write XML document to the specified output stream. 0N/A //Ignore the IAE. Should not fail the writeout even the 0N/A //transformer provider does not support "indent-number". 0N/A //Transformer resets the "indent" info if the "result" is a StreamResult with 0N/A //an OutputStream object embedded, creating a Writer object on top of that 0N/A //OutputStream object however works. 0N/A * Recursively traverse the specified preferences node and store 0N/A * the described preferences into the system or current user 0N/A * preferences tree, as appropriate. 0N/A * We first lock the node, import its contents and get 0N/A * child nodes. Then we unlock the node and go to children 0N/A * Since some of the children might have been concurrently 0N/A * deleted we check for this. 0N/A //If removed, return silently 0N/A // Import any preferences at this node 0N/A // Get involved children 0N/A }
// unlocked the node 0N/A * Import the preferences described by the specified XML element 0N/A * (a map from a preferences document) into the specified 0N/A * Export the specified Map<String,String> to a map document on 0N/A * the specified OutputStream as per the prefs DTD. This is used 0N/A * as the internal (undocumented) format for FileSystemPrefs. 0N/A * @throws IOException if writing to the specified output stream 0N/A * results in an <tt>IOException</tt>. 0N/A * Import Map from the specified input stream, which is assumed 0N/A * to contain a map document as per the prefs DTD. This is used 0N/A * as the internal (undocumented) format for FileSystemPrefs. The 0N/A * key-value pairs specified in the XML document will be put into 0N/A * the specified Map. (If this Map is empty, it will contain exactly 0N/A * the key-value pairs int the XML-document when this method returns.) 0N/A * @throws IOException if reading from the specified output stream 0N/A * results in an <tt>IOException</tt>. 0N/A * @throws InvalidPreferencesFormatException Data on input stream does not 0N/A * constitute a valid XML document with the mandated document type. 0N/A " is not supported. This java installation can read" +
0N/A " to install a newer version of JDK.");