src/share/classes/sun/util/xml/PrefsXmlSupport.java
author Jaroslav Tulach <jtulach@netbeans.org>
Wed, 24 Jun 2009 17:29:29 +0200
branchxml-sax-and-dom-2
changeset 1263 24b6c30fbf71
parent 1260 1ef89a94ad93
permissions -rw-r--r--
Simple output of Preferences is the same as the original one via DOM
duke@0
     1
/*
duke@0
     2
 * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
duke@0
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0
     4
 *
duke@0
     5
 * This code is free software; you can redistribute it and/or modify it
duke@0
     6
 * under the terms of the GNU General Public License version 2 only, as
duke@0
     7
 * published by the Free Software Foundation.  Sun designates this
duke@0
     8
 * particular file as subject to the "Classpath" exception as provided
duke@0
     9
 * by Sun in the LICENSE file that accompanied this code.
duke@0
    10
 *
duke@0
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
duke@0
    14
 * version 2 for more details (a copy is included in the LICENSE file that
duke@0
    15
 * accompanied this code).
duke@0
    16
 *
duke@0
    17
 * You should have received a copy of the GNU General Public License version
duke@0
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0
    20
 *
duke@0
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0
    23
 * have any questions.
duke@0
    24
 */
duke@0
    25
jtulach@1260
    26
package sun.util.xml;
duke@0
    27
duke@0
    28
import java.util.*;
jtulach@1260
    29
import java.util.prefs.*;
duke@0
    30
import java.io.*;
duke@0
    31
duke@0
    32
/**
duke@0
    33
 * XML Support for java.util.prefs. Methods to import and export preference
duke@0
    34
 * nodes and subtrees.
duke@0
    35
 *
duke@0
    36
 * @author  Josh Bloch and Mark Reinhold
duke@0
    37
 * @see     Preferences
duke@0
    38
 * @since   1.4
duke@0
    39
 */
jtulach@1260
    40
public abstract class PrefsXmlSupport {
jtulach@1260
    41
    public static PrefsXmlSupport getDefault() {
jtulach@1260
    42
        Iterator<PrefsXmlSupport> it = ServiceLoader.load(PrefsXmlSupport.class).iterator();
jtulach@1263
    43
        return it.hasNext() ? it.next() : new DefaultPrefsXmlSupport();
duke@0
    44
    }
duke@0
    45
jtulach@1260
    46
    public abstract void export(OutputStream os, final Preferences p, boolean subTree)
jtulach@1260
    47
        throws IOException, BackingStoreException;
duke@0
    48
duke@0
    49
    /**
duke@0
    50
     * Import preferences from the specified input stream, which is assumed
duke@0
    51
     * to contain an XML document in the format described in the Preferences
duke@0
    52
     * spec.
duke@0
    53
     *
duke@0
    54
     * @throws IOException if reading from the specified output stream
duke@0
    55
     *         results in an <tt>IOException</tt>.
duke@0
    56
     * @throws InvalidPreferencesFormatException Data on input stream does not
duke@0
    57
     *         constitute a valid XML document with the mandated document type.
duke@0
    58
     */
jtulach@1260
    59
    public abstract void importPreferences(InputStream is)
jtulach@1260
    60
        throws IOException, InvalidPreferencesFormatException;
duke@0
    61
duke@0
    62
jtulach@1260
    63
    public abstract void importMap(InputStream is, Map m)
jtulach@1260
    64
        throws IOException, InvalidPreferencesFormatException;
duke@0
    65
jtulach@1260
    66
    public abstract void exportMap(OutputStream is, Map m)
jtulach@1260
    67
        throws IOException, InvalidPreferencesFormatException;
duke@0
    68
duke@0
    69
}