1 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 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 List _rules; 40 41 private List _shareableRules; 42 43 private String _contentTranslator; 44 45 private String _keyAttribute; 46 47 public ElementModelImpl(String moduleId) 48 { 49 super(moduleId); 50 } 51 52 public String getElementName() 53 { 54 return _elementName; 55 } 56 57 public void setElementName(String string) 58 { 59 _elementName = string; 60 } 61 62 public void addAttributeModel(AttributeModel attributeModel) 63 { 64 if (_attributeModels == null) 65 _attributeModels = new ArrayList (); 66 67 _attributeModels.add(attributeModel); 68 _shareableAttributeModels = null; 69 } 70 71 public List 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 name) 81 { 82 if (_attributeModels == null) 83 return null; 84 85 for (Iterator 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 (); 100 101 _rules.add(rule); 102 _shareableRules = null; 103 } 104 105 public List 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 getContentTranslator() 115 { 116 return _contentTranslator; 117 } 118 119 public void setContentTranslator(String string) 120 { 121 _contentTranslator = string; 122 } 123 124 public String getKeyAttribute() 125 { 126 return _keyAttribute; 127 } 128 129 public void setKeyAttribute(String keyAttribute) 130 { 131 _keyAttribute = keyAttribute; 132 } 133 134 } | Popular Tags |