1 19 20 package org.netbeans.modules.xml.schema.model.impl; 21 22 import org.netbeans.modules.xml.schema.model.*; 23 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor; 24 import org.w3c.dom.Element ; 25 26 29 public class SequenceImpl extends SchemaComponentImpl 30 implements Sequence, Cardinality { 31 32 public SequenceImpl(SchemaModelImpl model) { 33 this(model, createNewComponent(SchemaElements.SEQUENCE,model)); 34 } 35 36 public SequenceImpl(SchemaModelImpl model, Element e) { 37 super(model,e); 38 } 39 40 public void removeContent(SequenceDefinition definition) { 41 removeChild(CONTENT_PROPERTY, definition); 42 } 43 44 public void addContent(SequenceDefinition definition, int position) { 45 insertAtIndex(CONTENT_PROPERTY, definition, position, 46 SequenceDefinition.class); 47 } 48 49 public void appendContent(SequenceDefinition definition) { 50 appendChild(CONTENT_PROPERTY, definition); 51 } 52 53 public java.util.List <SequenceDefinition> getContent() { 54 return getChildren(SequenceDefinition.class); 55 } 56 57 public Class <? extends SchemaComponent> getComponentType() { 58 return Sequence.class; 59 } 60 61 public void accept(SchemaVisitor v) { 62 v.visit(this); 63 } 64 65 public void setMinOccurs(Integer min) { 66 setAttribute(MIN_OCCURS_PROPERTY, SchemaAttributes.MIN_OCCURS, min); 67 } 68 69 public void setMaxOccurs(String max) { 70 setAttribute(MAX_OCCURS_PROPERTY, SchemaAttributes.MAX_OCCURS, max); 71 } 72 73 public Integer getMinOccurs() { 74 String s = getAttribute(SchemaAttributes.MIN_OCCURS); 75 return s == null ? null : Integer.valueOf(s); 76 } 77 78 public String getMaxOccurs() { 79 return getAttribute(SchemaAttributes.MAX_OCCURS); 80 } 81 82 public int getMinOccursEffective() { 83 Integer v = getMinOccurs(); 84 return v == null ? getMinOccursDefault() : v; 85 } 86 87 public int getMinOccursDefault() { 88 return 1; 89 } 90 91 public String getMaxOccursEffective() { 92 String v = getMaxOccurs(); 93 return v == null ? getMaxOccursDefault() : v; 94 } 95 96 public String getMaxOccursDefault() { 97 return String.valueOf(1); 98 } 99 100 public Cardinality getCardinality() { 101 return getParent() instanceof GlobalGroup ? null: this; 102 } 103 104 } 105 | Popular Tags |