src/share/classes/java/util/prefs/XmlSupport.java

Print this page




  75     /**
  76      * Version number for the format exported preferences files.
  77      */
  78     private static final String EXTERNAL_XML_VERSION = "1.0";
  79 
  80     /*
  81      * Version number for the internal map files.
  82      */
  83     private static final String MAP_XML_VERSION = "1.0";
  84 
  85     /**
  86      * Export the specified preferences node and, if subTree is true, all
  87      * subnodes, to the specified output stream.  Preferences are exported as
  88      * an XML document conforming to the definition in the Preferences spec.
  89      *
  90      * @throws IOException if writing to the specified output stream
  91      *         results in an <tt>IOException</tt>.
  92      * @throws BackingStoreException if preference data cannot be read from
  93      *         backing store.
  94      * @throws IllegalStateException if this node (or an ancestor) has been
  95      *         removed with the {@link #removeNode()} method.
  96      */
  97     static void export(OutputStream os, final Preferences p, boolean subTree)
  98         throws IOException, BackingStoreException {
  99         if (((AbstractPreferences)p).isRemoved())
 100             throw new IllegalStateException("Node has been removed");
 101         Document doc = createPrefsDoc("preferences");
 102         Element preferences =  doc.getDocumentElement() ;
 103         preferences.setAttribute("EXTERNAL_XML_VERSION", EXTERNAL_XML_VERSION);
 104         Element xmlRoot =  (Element)
 105         preferences.appendChild(doc.createElement("root"));
 106         xmlRoot.setAttribute("type", (p.isUserNode() ? "user" : "system"));
 107 
 108         // Get bottom-up list of nodes from p to root, excluding root
 109         List<Preferences> ancestors = new ArrayList<>();
 110 
 111         for (Preferences kid = p, dad = kid.parent(); dad != null;
 112                                    kid = dad, dad = kid.parent()) {
 113             ancestors.add(kid);
 114         }
 115         Element e = xmlRoot;




  75     /**
  76      * Version number for the format exported preferences files.
  77      */
  78     private static final String EXTERNAL_XML_VERSION = "1.0";
  79 
  80     /*
  81      * Version number for the internal map files.
  82      */
  83     private static final String MAP_XML_VERSION = "1.0";
  84 
  85     /**
  86      * Export the specified preferences node and, if subTree is true, all
  87      * subnodes, to the specified output stream.  Preferences are exported as
  88      * an XML document conforming to the definition in the Preferences spec.
  89      *
  90      * @throws IOException if writing to the specified output stream
  91      *         results in an <tt>IOException</tt>.
  92      * @throws BackingStoreException if preference data cannot be read from
  93      *         backing store.
  94      * @throws IllegalStateException if this node (or an ancestor) has been
  95      *         removed with the {@link Preferences#removeNode()} method.
  96      */
  97     static void export(OutputStream os, final Preferences p, boolean subTree)
  98         throws IOException, BackingStoreException {
  99         if (((AbstractPreferences)p).isRemoved())
 100             throw new IllegalStateException("Node has been removed");
 101         Document doc = createPrefsDoc("preferences");
 102         Element preferences =  doc.getDocumentElement() ;
 103         preferences.setAttribute("EXTERNAL_XML_VERSION", EXTERNAL_XML_VERSION);
 104         Element xmlRoot =  (Element)
 105         preferences.appendChild(doc.createElement("root"));
 106         xmlRoot.setAttribute("type", (p.isUserNode() ? "user" : "system"));
 107 
 108         // Get bottom-up list of nodes from p to root, excluding root
 109         List<Preferences> ancestors = new ArrayList<>();
 110 
 111         for (Preferences kid = p, dad = kid.parent(); dad != null;
 112                                    kid = dad, dad = kid.parent()) {
 113             ancestors.add(kid);
 114         }
 115         Element e = xmlRoot;