KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > util > ConstructableProperties


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the license.html file. *
7  * *
8  * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
9  *****************************************************************************/

10 package org.picocontainer.gems.util;
11
12
13 import java.util.Properties JavaDoc;
14 import java.io.IOException JavaDoc;
15 import java.io.InputStream JavaDoc;
16
17 /**
18  * constructable properties.
19  *
20  * @author Konstantin Pribluda ( ko5tik[at]codehaus.org )
21  * @version $Revision: 2002 $
22  */

23 public class ConstructableProperties extends Properties JavaDoc {
24
25     /**
26      * create properties from classpath resource using context classloader
27      *
28      * @param resource resource name
29      * @exception IOException passed from Properties.load()
30      */

31     public ConstructableProperties(String JavaDoc resource) throws IOException JavaDoc {
32         super();
33         load(Thread.currentThread().getContextClassLoader().getResourceAsStream(resource));
34     }
35     /**
36      *
37      * @param resource resource name
38      * @param defaults default properties
39      * @throws IOException can be thrown if something goes wrong
40      */

41     public ConstructableProperties(String JavaDoc resource, Properties JavaDoc defaults) throws IOException JavaDoc {
42         super(defaults);
43         load(Thread.currentThread().getContextClassLoader().getResourceAsStream(resource));
44     }
45     
46     /**
47      * create properties from input stream
48      * @param stream to read from
49      * @throws IOException can be thrown by properties objkect
50      */

51     public ConstructableProperties(InputStream JavaDoc stream) throws IOException JavaDoc {
52         super();
53         load(stream);
54     }
55     /**
56      * create from inpiut stream with default properties
57      * @param stream to read from
58      * @param defaults default properties
59      * @throws IOException can be thrown by properties object
60      */

61     public ConstructableProperties(InputStream JavaDoc stream, Properties JavaDoc defaults) throws IOException JavaDoc {
62         super(defaults);
63         load(stream);
64     }
65 }
66
Popular Tags