|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ElementModelImpl.java | 83.3% | 96.3% | 100% | 92.9% |
|
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;
|
|
18 |
import java.util.Collections;
|
|
19 |
import java.util.Iterator;
|
|
20 |
import java.util.List;
|
|
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 _elementName;
|
|
34 |
|
|
35 |
private List _attributeModels;
|
|
36 |
|
|
37 |
private List _shareableAttributeModels;
|
|
38 |
|
|
39 |
private String _keyAttribute;
|
|
40 |
|
|
41 |
private List _rules;
|
|
42 |
|
|
43 |
private List _shareableRules;
|
|
44 |
|
|
45 |
private String _contentTranslator;
|
|
46 |
|
|
47 | 8719 |
public String getElementName()
|
48 |
{ |
|
49 | 8719 |
return _elementName;
|
50 |
} |
|
51 |
|
|
52 | 3375 |
public void setElementName(String string) |
53 |
{ |
|
54 | 3375 |
_elementName = string; |
55 |
} |
|
56 |
|
|
57 | 4247 |
public void addAttributeModel(AttributeModel attributeModel) |
58 |
{ |
|
59 | 4247 |
if (_attributeModels == null) |
60 | 1771 |
_attributeModels = new ArrayList();
|
61 |
|
|
62 | 4247 |
_attributeModels.add(attributeModel); |
63 | 4247 |
_shareableAttributeModels = null;
|
64 |
} |
|
65 |
|
|
66 | 9150 |
public List getAttributeModels()
|
67 |
{ |
|
68 | 9150 |
if (_shareableAttributeModels == null) |
69 | 3021 |
_shareableAttributeModels = _attributeModels == null ? Collections.EMPTY_LIST
|
70 |
: Collections.unmodifiableList(_attributeModels); |
|
71 |
|
|
72 | 9150 |
return _shareableAttributeModels;
|
73 |
} |
|
74 |
|
|
75 | 107 |
public AttributeModel getAttributeModel(String name)
|
76 |
{ |
|
77 | 107 |
if (_attributeModels == null) |
78 | 1 |
return null; |
79 |
|
|
80 | 106 |
for (Iterator i = _attributeModels.iterator(); i.hasNext();)
|
81 |
{ |
|
82 | 106 |
AttributeModel am = (AttributeModel) i.next(); |
83 |
|
|
84 | 106 |
if (am.getName().equals(name))
|
85 | 106 |
return am;
|
86 |
} |
|
87 |
|
|
88 | 0 |
return null; |
89 |
} |
|
90 |
|
|
91 | 3372 |
public void setKeyAttribute(String keyAttribute) |
92 |
{ |
|
93 | 3372 |
_keyAttribute = keyAttribute; |
94 |
} |
|
95 |
|
|
96 | 11490 |
public String getKeyAttribute()
|
97 |
{ |
|
98 | 11490 |
return _keyAttribute;
|
99 |
} |
|
100 |
|
|
101 | 12586 |
public void addRule(Rule rule) |
102 |
{ |
|
103 | 12586 |
if (_rules == null) |
104 | 3363 |
_rules = new ArrayList();
|
105 |
|
|
106 | 12586 |
_rules.add(rule); |
107 | 12586 |
_shareableRules = null;
|
108 |
} |
|
109 |
|
|
110 | 5984 |
public List getRules()
|
111 |
{ |
|
112 | 5984 |
if (_shareableRules == null) |
113 | 810 |
_shareableRules = _rules == null ? Collections.EMPTY_LIST : Collections
|
114 |
.unmodifiableList(_rules); |
|
115 |
|
|
116 | 5984 |
return _shareableRules;
|
117 |
} |
|
118 |
|
|
119 | 16 |
public String getContentTranslator()
|
120 |
{ |
|
121 | 16 |
return _contentTranslator;
|
122 |
} |
|
123 |
|
|
124 | 3372 |
public void setContentTranslator(String string) |
125 |
{ |
|
126 | 3372 |
_contentTranslator = string; |
127 |
} |
|
128 |
|
|
129 |
} |
|