1 /* 2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.util.spi; 27 28 import java.util.Properties; 29 import java.util.InvalidPropertiesFormatException; 30 import java.io.InputStream; 31 import java.io.OutputStream; 32 import java.io.IOException; 33 34 /** 35 * Service-provider class for loading and storing {@link Properites} in XML 36 * format. 37 * 38 * @see Properties#loadFromXML 39 * @see Properties#storeToXML 40 */ 41 42 public abstract class XmlPropertiesProvider { 43 44 /** 45 * Initializes a new instance of this class. 46 */ 47 protected XmlPropertiesProvider() { 48 // do nothing for now 49 } 50 51 /** 52 * Loads all of the properties represented by the XML document on the 53 * specified input stream into a properties table. 54 * 55 * @param props the properties table to populate 56 * @param in the input stream from which to read the XML document 57 * @throws IOException if reading from the specified input stream fails 58 * @throws InvalidPropertiesFormatException Data on input stream does not 59 * constitute a valid XML document with the mandated document type. 60 * 61 * @see Properties#loadFromXML 62 */ 63 public abstract void load(Properties props, InputStream in) 64 throws IOException, InvalidPropertiesFormatException; 65 66 /** 67 * Emits an XML document representing all of the properties in a given 68 * table. 69 * 70 * @param props the properies to store 71 * @param out the output stream on which to emit the XML document. 72 * @param comment a description of the property list, can be @{code null} 73 * @param encoding the name of a supported character encoding 74 * 75 * @throws IOException if writing to the specified output stream fails 76 * @throws NullPointerException if {@code out} is null. 77 * @throws ClassCastException if this {@code Properties} object 78 * contains any keys or values that are not 79 * {@code Strings}. 80 * 81 * @see Properties#storeToXML 82 */ 83 public abstract void store(Properties props, OutputStream out, 84 String comment, String encoding) 85 throws IOException; 86 }