KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > schema > impl > ElementModelImpl


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
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 implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.schema.impl;
16
17 import java.util.ArrayList JavaDoc;
18 import java.util.Collections JavaDoc;
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.hivemind.schema.AttributeModel;
23 import org.apache.hivemind.schema.ElementModel;
24 import org.apache.hivemind.schema.Rule;
25
26 /**
27  * Implementation of {@link org.apache.hivemind.schema.ElementModel}.
28  *
29  * @author Howard Lewis Ship
30  */

31 public class ElementModelImpl extends SchemaImpl implements ElementModel
32 {
33     private String JavaDoc _elementName;
34
35     private List JavaDoc _attributeModels;
36
37     private List JavaDoc _shareableAttributeModels;
38
39     private List JavaDoc _rules;
40
41     private List JavaDoc _shareableRules;
42
43     private String JavaDoc _contentTranslator;
44     
45     private String JavaDoc _keyAttribute;
46
47     public ElementModelImpl(String JavaDoc moduleId)
48     {
49         super(moduleId);
50     }
51
52     public String JavaDoc getElementName()
53     {
54         return _elementName;
55     }
56
57     public void setElementName(String JavaDoc string)
58     {
59         _elementName = string;
60     }
61
62     public void addAttributeModel(AttributeModel attributeModel)
63     {
64         if (_attributeModels == null)
65             _attributeModels = new ArrayList JavaDoc();
66
67         _attributeModels.add(attributeModel);
68         _shareableAttributeModels = null;
69     }
70
71     public List JavaDoc getAttributeModels()
72     {
73         if (_shareableAttributeModels == null)
74             _shareableAttributeModels = _attributeModels == null ? Collections.EMPTY_LIST
75                     : Collections.unmodifiableList(_attributeModels);
76
77         return _shareableAttributeModels;
78     }
79
80     public AttributeModel getAttributeModel(String JavaDoc name)
81     {
82         if (_attributeModels == null)
83             return null;
84
85         for (Iterator JavaDoc i = _attributeModels.iterator(); i.hasNext();)
86         {
87             AttributeModel am = (AttributeModel) i.next();
88
89             if (am.getName().equals(name))
90                 return am;
91         }
92
93         return null;
94     }
95
96     public void addRule(Rule rule)
97     {
98         if (_rules == null)
99             _rules = new ArrayList JavaDoc();
100
101         _rules.add(rule);
102         _shareableRules = null;
103     }
104
105     public List JavaDoc getRules()
106     {
107         if (_shareableRules == null)
108             _shareableRules = _rules == null ? Collections.EMPTY_LIST : Collections
109                     .unmodifiableList(_rules);
110
111         return _shareableRules;
112     }
113
114     public String JavaDoc getContentTranslator()
115     {
116         return _contentTranslator;
117     }
118
119     public void setContentTranslator(String JavaDoc string)
120     {
121         _contentTranslator = string;
122     }
123
124     public String JavaDoc getKeyAttribute()
125     {
126         return _keyAttribute;
127     }
128
129     public void setKeyAttribute(String JavaDoc keyAttribute)
130     {
131         _keyAttribute = keyAttribute;
132     }
133
134 }
Popular Tags