duke@0: /* duke@0: * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved. duke@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@0: * duke@0: * This code is free software; you can redistribute it and/or modify it duke@0: * under the terms of the GNU General Public License version 2 only, as duke@0: * published by the Free Software Foundation. Sun designates this duke@0: * particular file as subject to the "Classpath" exception as provided duke@0: * by Sun in the LICENSE file that accompanied this code. duke@0: * duke@0: * This code is distributed in the hope that it will be useful, but WITHOUT duke@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@0: * version 2 for more details (a copy is included in the LICENSE file that duke@0: * accompanied this code). duke@0: * duke@0: * You should have received a copy of the GNU General Public License version duke@0: * 2 along with this work; if not, write to the Free Software Foundation, duke@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@0: * duke@0: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@0: * CA 95054 USA or visit www.sun.com if you need additional information or duke@0: * have any questions. duke@0: */ duke@0: jtulach@1260: package sun.util.xml; duke@0: duke@0: import java.util.*; jtulach@1260: import java.util.prefs.*; duke@0: import java.io.*; duke@0: duke@0: /** duke@0: * XML Support for java.util.prefs. Methods to import and export preference duke@0: * nodes and subtrees. duke@0: * duke@0: * @author Josh Bloch and Mark Reinhold duke@0: * @see Preferences duke@0: * @since 1.4 duke@0: */ jtulach@1260: public abstract class PrefsXmlSupport { jtulach@1260: public static PrefsXmlSupport getDefault() { jtulach@1260: Iterator it = ServiceLoader.load(PrefsXmlSupport.class).iterator(); jtulach@1263: return it.hasNext() ? it.next() : new DefaultPrefsXmlSupport(); duke@0: } duke@0: jtulach@1260: public abstract void export(OutputStream os, final Preferences p, boolean subTree) jtulach@1260: throws IOException, BackingStoreException; duke@0: duke@0: /** duke@0: * Import preferences from the specified input stream, which is assumed duke@0: * to contain an XML document in the format described in the Preferences duke@0: * spec. duke@0: * duke@0: * @throws IOException if reading from the specified output stream duke@0: * results in an IOException. duke@0: * @throws InvalidPreferencesFormatException Data on input stream does not duke@0: * constitute a valid XML document with the mandated document type. duke@0: */ jtulach@1260: public abstract void importPreferences(InputStream is) jtulach@1260: throws IOException, InvalidPreferencesFormatException; duke@0: duke@0: jtulach@1260: public abstract void importMap(InputStream is, Map m) jtulach@1260: throws IOException, InvalidPreferencesFormatException; duke@0: jtulach@1260: public abstract void exportMap(OutputStream is, Map m) jtulach@1260: throws IOException, InvalidPreferencesFormatException; duke@0: duke@0: }