1 19 20 package org.netbeans.modules.xml.schema.model.impl; 21 22 import java.util.Collection ; 23 import org.netbeans.modules.xml.schema.model.All; 24 import org.netbeans.modules.xml.schema.model.ElementReference; 25 import org.netbeans.modules.xml.schema.model.GlobalGroup; 26 import org.netbeans.modules.xml.schema.model.LocalElement; 27 import org.netbeans.modules.xml.schema.model.SchemaComponent; 28 import org.netbeans.modules.xml.schema.model.Occur; 29 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor; 30 import org.w3c.dom.Element ; 31 32 38 public class AllImpl extends SchemaComponentImpl implements All { 39 40 public AllImpl(SchemaModelImpl model) { 41 this(model,createNewComponent(SchemaElements.ALL, model)); 42 } 43 44 45 public AllImpl(SchemaModelImpl model, Element e) { 46 super(model, e); 47 } 48 49 public Class <? extends SchemaComponent> getComponentType() { 50 return All.class; 51 } 52 53 public void accept(SchemaVisitor visitor) { 54 visitor.visit(this); 55 } 56 57 protected Class getAttributeType(SchemaAttributes attr) { 58 switch(attr) { 59 case MIN_OCCURS: 60 return Occur.ZeroOne.class; 61 default: 62 return super.getAttributeType(attr); 63 } 64 } 65 66 67 70 public Occur.ZeroOne getMinOccurs() { 71 String s = super.getAttribute(SchemaAttributes.MIN_OCCURS); 72 return s == null ? null : Util.parse(Occur.ZeroOne.class, s); 73 } 74 75 79 public void setMinOccurs(Occur.ZeroOne occurs) { 80 setAttribute(MIN_OCCURS_PROPERTY, SchemaAttributes.MIN_OCCURS, occurs); 81 } 82 83 public Occur.ZeroOne getMinOccursDefault() { 84 return Occur.ZeroOne.ONE; 85 } 86 87 public Occur.ZeroOne getMinOccursEffective() { 88 Occur.ZeroOne v = getMinOccurs(); 89 return v == null ? getMinOccursDefault() : v; 90 } 91 92 public Collection <LocalElement> getElements() { 93 return super.getChildren(LocalElement.class); 94 } 95 96 public void addElement(LocalElement e) { 97 appendChild(ELEMENT_PROPERTY, e); 98 } 99 100 public void removeElement(LocalElement e) { 101 removeChild(ELEMENT_PROPERTY, e); 102 } 103 104 public Collection <ElementReference> getElementReferences() { 105 return super.getChildren(ElementReference.class); 106 } 107 108 public void addElementReference(ElementReference e) { 109 appendChild(ELEMENT_REFERENCE_PROPERTY, e); 110 } 111 112 public void removeElementReference(ElementReference e) { 113 removeChild(ELEMENT_REFERENCE_PROPERTY, e); 114 } 115 116 public boolean allowsFullMultiplicity() { 117 return !(getParent() instanceof GlobalGroup); 118 } 119 } 120 | Popular Tags |