Clover coverage report - Code Coverage for hivemind release 1.1-beta-2
Coverage timestamp: Tue Jun 28 2005 10:28:23 EDT
file stats: LOC: 129   Methods: 11
NCLOC: 81   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ElementModelImpl.java 83.3% 96.3% 100% 92.9%
coverage coverage
 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  10570 public String getElementName()
 48    {
 49  10570 return _elementName;
 50    }
 51   
 52  3967 public void setElementName(String string)
 53    {
 54  3967 _elementName = string;
 55    }
 56   
 57  4991 public void addAttributeModel(AttributeModel attributeModel)
 58    {
 59  4991 if (_attributeModels == null)
 60  2077 _attributeModels = new ArrayList();
 61   
 62  4991 _attributeModels.add(attributeModel);
 63  4991 _shareableAttributeModels = null;
 64    }
 65   
 66  11078 public List getAttributeModels()
 67    {
 68  11078 if (_shareableAttributeModels == null)
 69  3555 _shareableAttributeModels = _attributeModels == null ? Collections.EMPTY_LIST
 70    : Collections.unmodifiableList(_attributeModels);
 71   
 72  11078 return _shareableAttributeModels;
 73    }
 74   
 75  126 public AttributeModel getAttributeModel(String name)
 76    {
 77  126 if (_attributeModels == null)
 78  1 return null;
 79   
 80  125 for (Iterator i = _attributeModels.iterator(); i.hasNext();)
 81    {
 82  125 AttributeModel am = (AttributeModel) i.next();
 83   
 84  125 if (am.getName().equals(name))
 85  125 return am;
 86    }
 87   
 88  0 return null;
 89    }
 90   
 91  3963 public void setKeyAttribute(String keyAttribute)
 92    {
 93  3963 _keyAttribute = keyAttribute;
 94    }
 95   
 96  13857 public String getKeyAttribute()
 97    {
 98  13857 return _keyAttribute;
 99    }
 100   
 101  14572 public void addRule(Rule rule)
 102    {
 103  14572 if (_rules == null)
 104  3955 _rules = new ArrayList();
 105   
 106  14572 _rules.add(rule);
 107  14572 _shareableRules = null;
 108    }
 109   
 110  7581 public List getRules()
 111    {
 112  7581 if (_shareableRules == null)
 113  949 _shareableRules = _rules == null ? Collections.EMPTY_LIST : Collections
 114    .unmodifiableList(_rules);
 115   
 116  7581 return _shareableRules;
 117    }
 118   
 119  16 public String getContentTranslator()
 120    {
 121  16 return _contentTranslator;
 122    }
 123   
 124  3963 public void setContentTranslator(String string)
 125    {
 126  3963 _contentTranslator = string;
 127    }
 128   
 129    }