KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > config > ConfigSectionImpl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.config;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.List JavaDoc;
21
22 /**
23  * Default implementation of a config section
24  *
25  * @author gavinc
26  */

27 public class ConfigSectionImpl implements ConfigSection
28 {
29     private String JavaDoc evaluator;
30     private String JavaDoc condition;
31     private boolean replace = false;
32     private List JavaDoc<ConfigElement> configElements;
33
34     public ConfigSectionImpl(String JavaDoc evaluator, String JavaDoc condition, boolean replace)
35     {
36         this.evaluator = evaluator;
37         this.condition = condition;
38         this.replace = replace;
39         this.configElements = new ArrayList JavaDoc<ConfigElement>();
40     }
41
42     /**
43      * @see org.alfresco.config.ConfigSection#getEvaluator()
44      */

45     public String JavaDoc getEvaluator()
46     {
47         return this.evaluator;
48     }
49
50     /**
51      * @see org.alfresco.config.ConfigSection#getCondition()
52      */

53     public String JavaDoc getCondition()
54     {
55         return this.condition;
56     }
57
58     /**
59      * @see org.alfresco.config.ConfigSection#getConfigElements()
60      */

61     public List JavaDoc<ConfigElement> getConfigElements()
62     {
63         return this.configElements;
64     }
65
66     /**
67      * Adds a config element to the results for the lookup
68      *
69      * @param configElement
70      */

71     public void addConfigElement(ConfigElement configElement)
72     {
73         this.configElements.add(configElement);
74     }
75
76     /**
77      * @see org.alfresco.config.ConfigSection#isGlobal()
78      */

79     public boolean isGlobal()
80     {
81         boolean global = false;
82
83         if (this.evaluator == null
84                 || this.evaluator.length() == 0
85                 || this.condition == null
86                 || this.condition.length() == 0)
87         {
88             global = true;
89         }
90
91         return global;
92     }
93     
94     /**
95      * @see org.alfresco.config.ConfigSection#isReplace()
96      */

97     public boolean isReplace()
98     {
99        return this.replace;
100     }
101
102     public String JavaDoc toString()
103     {
104         StringBuilder JavaDoc buffer = new StringBuilder JavaDoc(super.toString());
105         buffer.append(" (evaluator=").append(this.evaluator);
106         buffer.append(" condition=").append(this.condition);
107         buffer.append(" replace=").append(this.replace).append(")");
108         return buffer.toString();
109     }
110 }
111
Popular Tags