KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > util > defaults > SimpleDefaultsFinder


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

17
18 package org.apache.avalon.util.defaults ;
19
20
21 import java.util.Properties JavaDoc ;
22
23
24 /**
25  * Attempts to discover defaults using an array of Properties as value sources.
26  *
27  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
28  * @version $Revision: 1.3 $
29  */

30 public class SimpleDefaultsFinder implements DefaultsFinder
31 {
32     /** Properties array to use for discovery */
33     private Properties JavaDoc [] m_sources ;
34     /** halt on first finding flag */
35     private boolean m_haltOnDiscovery = true ;
36     
37     
38     /**
39      * Creates a simple defaults finder that searches a single source Properties
40      * instance for default values.
41      *
42      * @param source single source Properties to discover values in
43      */

44     public SimpleDefaultsFinder( Properties JavaDoc source )
45     {
46         m_sources = new Properties JavaDoc [] { source } ;
47         m_haltOnDiscovery = false ;
48     }
49     
50     
51     /**
52      * Creates a simple defaults filder that searches a set of source Properties
53      * for default values.
54      *
55      * @param sources the source Properties to discover values in
56      * @param haltOnDiscovery true to halt search when first value is
57      * discovered, false to continue search overriding values until the last
58      * value is discovered.
59      */

60     public SimpleDefaultsFinder( Properties JavaDoc [] sources,
61                                    boolean haltOnDiscovery )
62     {
63         m_sources = sources ;
64         m_haltOnDiscovery = haltOnDiscovery ;
65     }
66     
67     
68     /**
69      * Applies default discovery using properties in array of properties.
70      *
71      * @see org.apache.avalon.util.defaults.DefaultsFinder#find(
72      * org.apache.avalon.util.defaults.Defaults)
73      */

74     public void find( Defaults a_defaults )
75     {
76         Defaults.discover( a_defaults, m_sources, m_haltOnDiscovery ) ;
77     }
78 }
79
Popular Tags