KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > util > PropertiesPersister


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.util;
18
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21 import java.io.OutputStream JavaDoc;
22 import java.io.Reader JavaDoc;
23 import java.io.Writer JavaDoc;
24 import java.util.Properties JavaDoc;
25
26 /**
27  * Strategy interface for persisting <code>java.util.Properties</code>,
28  * allowing for pluggable parsing strategies.
29  *
30  * <p>The default implementation is DefaultPropertiesPersister,
31  * providing the native parsing of <code>java.util.Properties</code>,
32  * but allowing for reading from any Reader and writing to any Writer
33  * (which allows to specify an encoding for a properties file).
34  *
35  * <p>As of Spring 1.2.2, this interface also supports properties XML files,
36  * through the <code>loadFromXml</code> and <code>storeToXml</code> methods.
37  * The default implementations delegate to JDK 1.5's corresponding methods.
38  *
39  * @author Juergen Hoeller
40  * @since 10.03.2004
41  * @see DefaultPropertiesPersister
42  * @see java.util.Properties
43  */

44 public interface PropertiesPersister {
45
46     /**
47      * Load properties from the given InputStream into the given
48      * Properties object.
49      * @param props the Properties object to load into
50      * @param is the InputStream to load from
51      * @throws IOException in case of I/O errors
52      * @see java.util.Properties#load
53      */

54     void load(Properties JavaDoc props, InputStream JavaDoc is) throws IOException JavaDoc;
55
56     /**
57      * Load properties from the given Reader into the given
58      * Properties object.
59      * @param props the Properties object to load into
60      * @param reader the Reader to load from
61      * @throws IOException in case of I/O errors
62      */

63     void load(Properties JavaDoc props, Reader JavaDoc reader) throws IOException JavaDoc;
64
65
66     /**
67      * Write the contents of the given Properties object to the
68      * given OutputStream.
69      * @param props the Properties object to store
70      * @param os the OutputStream to write to
71      * @param header the description of the property list
72      * @throws IOException in case of I/O errors
73      * @see java.util.Properties#store
74      */

75     void store(Properties JavaDoc props, OutputStream JavaDoc os, String JavaDoc header) throws IOException JavaDoc;
76
77     /**
78      * Write the contents of the given Properties object to the
79      * given Writer.
80      * @param props the Properties object to store
81      * @param writer the Writer to write to
82      * @param header the description of the property list
83      * @throws IOException in case of I/O errors
84      */

85     void store(Properties JavaDoc props, Writer JavaDoc writer, String JavaDoc header) throws IOException JavaDoc;
86
87
88     /**
89      * Load properties from the given XML InputStream into the
90      * given Properties object.
91      * @param props the Properties object to load into
92      * @param is the InputStream to load from
93      * @throws IOException in case of I/O errors
94      * @see java.util.Properties#loadFromXML(java.io.InputStream)
95      */

96     void loadFromXml(Properties JavaDoc props, InputStream JavaDoc is) throws IOException JavaDoc;
97
98     /**
99      * Write the contents of the given Properties object to the
100      * given XML OutputStream.
101      * @param props the Properties object to store
102      * @param os the OutputStream to write to
103      * @param header the description of the property list
104      * @throws IOException in case of I/O errors
105      * @see java.util.Properties#storeToXML(java.io.OutputStream, String)
106      */

107     void storeToXml(Properties JavaDoc props, OutputStream JavaDoc os, String JavaDoc header) throws IOException JavaDoc;
108
109     /**
110      * Write the contents of the given Properties object to the
111      * given XML OutputStream.
112      * @param props the Properties object to store
113      * @param os the OutputStream to write to
114      * @param encoding the encoding to use
115      * @param header the description of the property list
116      * @throws IOException in case of I/O errors
117      * @see java.util.Properties#storeToXML(java.io.OutputStream, String, String)
118      */

119     void storeToXml(Properties JavaDoc props, OutputStream JavaDoc os, String JavaDoc header, String JavaDoc encoding) throws IOException JavaDoc;
120
121 }
122
Popular Tags