1 19 20 package org.netbeans.modules.xml.schema.model.impl; 21 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 import java.util.List ; 25 import org.netbeans.modules.xml.schema.model.Annotation; 26 import org.netbeans.modules.xml.schema.model.AnyAttribute; 27 import org.netbeans.modules.xml.schema.model.AttributeGroupReference; 28 import org.netbeans.modules.xml.schema.model.Attribute; 29 import org.netbeans.modules.xml.schema.model.GlobalType; 30 import org.netbeans.modules.xml.schema.model.SimpleRestriction; 31 import org.netbeans.modules.xml.schema.model.Enumeration; 32 import org.netbeans.modules.xml.schema.model.FractionDigits; 33 import org.netbeans.modules.xml.schema.model.GlobalSimpleType; 34 import org.netbeans.modules.xml.schema.model.Length; 35 import org.netbeans.modules.xml.schema.model.LocalSimpleType; 36 import org.netbeans.modules.xml.schema.model.MaxExclusive; 37 import org.netbeans.modules.xml.schema.model.MaxInclusive; 38 import org.netbeans.modules.xml.schema.model.MaxLength; 39 import org.netbeans.modules.xml.schema.model.MinExclusive; 40 import org.netbeans.modules.xml.schema.model.MinInclusive; 41 import org.netbeans.modules.xml.schema.model.MinLength; 42 import org.netbeans.modules.xml.schema.model.Pattern; 43 import org.netbeans.modules.xml.schema.model.SchemaComponent; 44 import org.netbeans.modules.xml.schema.model.TotalDigits; 45 import org.netbeans.modules.xml.schema.model.Whitespace; 46 import org.netbeans.modules.xml.xam.dom.NamedComponentReference; 47 import org.w3c.dom.Element ; 48 49 53 public abstract class CommonSimpleRestrictionImpl extends SchemaComponentImpl implements SimpleRestriction{ 54 55 56 public CommonSimpleRestrictionImpl(SchemaModelImpl model, Element el) { 57 super(model, el); 58 } 59 60 public void addEnumeration(Enumeration fd) { 61 addBefore(ENUMERATION_PROPERTY, fd, getAttributeClasses()); 62 } 63 64 public void removeEnumeration(Enumeration fd) { 65 removeChild(ENUMERATION_PROPERTY, fd); 66 } 67 68 public Collection <Enumeration> getEnumerations() { 69 return getChildren(Enumeration.class); 70 } 71 72 public void removePattern(Pattern p) { 73 removeChild(PATTERN_PROPERTY, p); 74 } 75 76 public void addPattern(Pattern p) { 77 addBefore(PATTERN_PROPERTY, p, getAttributeClasses()); 78 } 79 80 public Collection <Pattern> getPatterns() { 81 return getChildren(Pattern.class); 82 } 83 84 public void removeMinExclusive(MinExclusive me) { 85 removeChild(MIN_EXCLUSIVE_PROPERTY, me); 86 } 87 88 public void addMinExclusive(MinExclusive me) { 89 addBefore(MIN_EXCLUSIVE_PROPERTY, me, getAttributeClasses()); 90 } 91 92 public Collection <MinExclusive> getMinExclusives() { 93 return getChildren(MinExclusive.class); 94 } 95 96 public void removeMinLength(MinLength ml) { 97 removeChild(MIN_LENGTH_PROPERTY, ml); 98 } 99 100 public void addMinLength(MinLength ml) { 101 addBefore(MIN_LENGTH_PROPERTY, ml, getAttributeClasses()); 102 } 103 104 public Collection <MinLength> getMinLengths() { 105 return getChildren(MinLength.class); 106 } 107 108 public void removeMaxLength(MaxLength ml) { 109 removeChild(MAX_LENGTH_PROPERTY, ml); 110 } 111 112 public void addMaxLength(MaxLength ml) { 113 addBefore(MAX_LENGTH_PROPERTY, ml, getAttributeClasses()); 114 } 115 116 public Collection <MaxLength> getMaxLengths() { 117 return getChildren(MaxLength.class); 118 } 119 120 public void removeFractionDigits(FractionDigits fd) { 121 removeChild(FRACTION_DIGITS_PROPERTY, fd); 122 } 123 124 public void addFractionDigits(FractionDigits fd) { 125 addBefore(FRACTION_DIGITS_PROPERTY, fd, getAttributeClasses()); 126 } 127 128 public Collection <FractionDigits> getFractionDigits() { 129 return getChildren(FractionDigits.class); 130 } 131 132 public void removeWhitespace(Whitespace me) { 133 removeChild(WHITESPACE_PROPERTY, me); 134 } 135 136 public void addWhitespace(Whitespace me) { 137 addBefore(WHITESPACE_PROPERTY, me, getAttributeClasses()); 138 } 139 140 public Collection <Whitespace> getWhitespaces() { 141 return getChildren(Whitespace.class); 142 } 143 144 145 public void removeMaxInclusive(MaxInclusive me) { 146 removeChild(MAX_INCLUSIVE_PROPERTY, me); 147 } 148 149 public void addMaxInclusive(MaxInclusive me) { 150 addBefore(MAX_INCLUSIVE_PROPERTY, me, getAttributeClasses()); 151 } 152 153 public Collection <MaxInclusive> getMaxInclusives() { 154 return getChildren(MaxInclusive.class); 155 } 156 157 public void removeTotalDigit(TotalDigits td) { 158 removeChild(TOTAL_DIGITS_PROPERTY, td); 159 } 160 161 public void addTotalDigit(TotalDigits td) { 162 addBefore(TOTAL_DIGITS_PROPERTY, td, getAttributeClasses()); 163 } 164 165 public Collection <TotalDigits> getTotalDigits() { 166 return getChildren(TotalDigits.class); 167 } 168 169 public void removeLength(Length me) { 170 removeChild(LENGTH_PROPERTY , me); 171 } 172 173 public void addLength(Length me) { 174 addBefore(LENGTH_PROPERTY, me, getAttributeClasses()); 175 } 176 177 public Collection <Length> getLengths() { 178 return getChildren(Length.class); 179 } 180 181 public void removeMinInclusive(MinInclusive me) { 182 removeChild(MIN_INCLUSIVE_PROPERTY, me); 183 } 184 185 public void addMinInclusive(MinInclusive me) { 186 addBefore(MIN_INCLUSIVE_PROPERTY, me, getAttributeClasses()); 187 } 188 189 public Collection <MinInclusive> getMinInclusives() { 190 return getChildren(MinInclusive.class); 191 } 192 193 public void removeMaxExclusive(MaxExclusive me) { 194 removeChild(MAX_EXCLUSIVE_PROPERTY, me); 195 } 196 197 public void addMaxExclusive(MaxExclusive me) { 198 addBefore(MAX_EXCLUSIVE_PROPERTY, me, getAttributeClasses()); 199 } 200 201 public Collection <MaxExclusive> getMaxExclusives() { 202 return getChildren(MaxExclusive.class); 203 } 204 205 public void setInlineType(LocalSimpleType aSimpleType) { 206 List <java.lang.Class <? extends SchemaComponent>> list = new ArrayList <java.lang.Class <? extends SchemaComponent>>(); 207 list.add(Annotation.class); 208 setChild(LocalSimpleType.class, INLINETYPE_PROPERTY, aSimpleType, list); 209 } 210 211 public LocalSimpleType getInlineType() { 212 Collection <LocalSimpleType> elements = getChildren(LocalSimpleType.class); 213 if(!elements.isEmpty()){ 214 return elements.iterator().next(); 215 } 216 return null; 217 } 218 219 private List <Class <? extends SchemaComponent>> getAttributeClasses(){ 220 List <java.lang.Class <? extends SchemaComponent>> list = new ArrayList <java.lang.Class <? extends SchemaComponent>>(); 221 list.add(Attribute.class); 222 list.add(AttributeGroupReference.class); 223 list.add(AnyAttribute.class); 224 225 return list; 226 } 227 } 228 | Popular Tags |